Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
80d45a69
Commit
80d45a69
authored
Nov 05, 2012
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12840: remove undocumented parameter "pass" from .attr. Close gh-1017.
parent
53cb49cb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
105 deletions
+33
-105
attributes.js
src/attributes.js
+3
-8
core.js
src/core.js
+30
-19
attributes.js
test/unit/attributes.js
+0
-78
No files found.
src/attributes.js
View file @
80d45a69
...
@@ -280,7 +280,7 @@ jQuery.extend({
...
@@ -280,7 +280,7 @@ jQuery.extend({
}
}
},
},
attr
:
function
(
elem
,
name
,
value
,
pass
)
{
attr
:
function
(
elem
,
name
,
value
)
{
var
ret
,
hooks
,
notxml
,
var
ret
,
hooks
,
notxml
,
nType
=
elem
.
nodeType
;
nType
=
elem
.
nodeType
;
...
@@ -289,10 +289,6 @@ jQuery.extend({
...
@@ -289,10 +289,6 @@ jQuery.extend({
return
;
return
;
}
}
if
(
pass
&&
jQuery
.
isFunction
(
jQuery
.
fn
[
name
]
)
)
{
return
jQuery
(
elem
)[
name
](
value
);
}
// Fallback to prop when attributes are not supported
// Fallback to prop when attributes are not supported
if
(
typeof
elem
.
getAttribute
===
"undefined"
)
{
if
(
typeof
elem
.
getAttribute
===
"undefined"
)
{
return
jQuery
.
prop
(
elem
,
name
,
value
);
return
jQuery
.
prop
(
elem
,
name
,
value
);
...
@@ -311,9 +307,8 @@ jQuery.extend({
...
@@ -311,9 +307,8 @@ jQuery.extend({
if
(
value
===
null
)
{
if
(
value
===
null
)
{
jQuery
.
removeAttr
(
elem
,
name
);
jQuery
.
removeAttr
(
elem
,
name
);
return
;
}
else
if
(
hooks
&&
"set"
in
hooks
&&
notxml
&&
(
ret
=
hooks
.
set
(
elem
,
value
,
name
))
!==
undefined
)
{
}
else
if
(
hooks
&&
notxml
&&
"set"
in
hooks
&&
(
ret
=
hooks
.
set
(
elem
,
value
,
name
))
!==
undefined
)
{
return
ret
;
return
ret
;
}
else
{
}
else
{
...
@@ -321,7 +316,7 @@ jQuery.extend({
...
@@ -321,7 +316,7 @@ jQuery.extend({
return
value
;
return
value
;
}
}
}
else
if
(
hooks
&&
"get"
in
hooks
&&
notxml
&&
(
ret
=
hooks
.
get
(
elem
,
name
))
!==
null
)
{
}
else
if
(
hooks
&&
notxml
&&
"get"
in
hooks
&&
(
ret
=
hooks
.
get
(
elem
,
name
))
!==
null
)
{
return
ret
;
return
ret
;
}
else
{
}
else
{
...
...
src/core.js
View file @
80d45a69
...
@@ -84,14 +84,14 @@ var
...
@@ -84,14 +84,14 @@ var
jQuery
.
fn
=
jQuery
.
prototype
=
{
jQuery
.
fn
=
jQuery
.
prototype
=
{
constructor
:
jQuery
,
constructor
:
jQuery
,
init
:
function
(
selector
,
context
,
rootjQuery
)
{
init
:
function
(
selector
,
context
,
rootjQuery
)
{
var
match
,
elem
,
doc
;
var
match
,
elem
;
// H
andle
$(""), $(null), $(undefined), $(false)
// H
ANDLE:
$(""), $(null), $(undefined), $(false)
if
(
!
selector
)
{
if
(
!
selector
)
{
return
this
;
return
this
;
}
}
// H
andle
$(DOMElement)
// H
ANDLE:
$(DOMElement)
if
(
selector
.
nodeType
)
{
if
(
selector
.
nodeType
)
{
this
.
context
=
this
[
0
]
=
selector
;
this
.
context
=
this
[
0
]
=
selector
;
this
.
length
=
1
;
this
.
length
=
1
;
...
@@ -114,15 +114,29 @@ jQuery.fn = jQuery.prototype = {
...
@@ -114,15 +114,29 @@ jQuery.fn = jQuery.prototype = {
// HANDLE: $(html) -> $(array)
// HANDLE: $(html) -> $(array)
if
(
match
[
1
]
)
{
if
(
match
[
1
]
)
{
context
=
context
instanceof
jQuery
?
context
[
0
]
:
context
;
context
=
context
instanceof
jQuery
?
context
[
0
]
:
context
;
doc
=
(
context
&&
context
.
nodeType
?
context
.
ownerDocument
||
context
:
document
);
// scripts is true for back-compat
// scripts is true for back-compat
selector
=
jQuery
.
parseHTML
(
match
[
1
],
doc
,
true
);
jQuery
.
merge
(
this
,
jQuery
.
parseHTML
(
match
[
1
],
context
&&
context
.
nodeType
?
context
.
ownerDocument
||
context
:
document
,
true
)
);
// HANDLE: $(html, props)
if
(
rsingleTag
.
test
(
match
[
1
]
)
&&
jQuery
.
isPlainObject
(
context
)
)
{
if
(
rsingleTag
.
test
(
match
[
1
]
)
&&
jQuery
.
isPlainObject
(
context
)
)
{
this
.
attr
.
call
(
selector
,
context
,
true
);
for
(
match
in
context
)
{
// Properties of context are called as methods if possible
if
(
jQuery
.
isFunction
(
this
[
match
]
)
)
{
this
[
match
](
context
[
match
]
);
// ...and otherwise set as attributes
}
else
{
this
.
attr
(
match
,
context
[
match
]
);
}
}
}
}
return
jQuery
.
merge
(
this
,
selector
)
;
return
this
;
// HANDLE: $(#id)
// HANDLE: $(#id)
}
else
{
}
else
{
...
@@ -768,23 +782,22 @@ jQuery.extend({
...
@@ -768,23 +782,22 @@ jQuery.extend({
// Multifunctional method to get and set values of a collection
// Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function
// The value/s can optionally be executed if it's a function
access
:
function
(
elems
,
fn
,
key
,
value
,
chainable
,
emptyGet
,
pass
)
{
access
:
function
(
elems
,
fn
,
key
,
value
,
chainable
,
emptyGet
)
{
var
exec
,
var
i
=
0
,
length
=
elems
.
length
,
bulk
=
key
==
null
,
bulk
=
key
==
null
,
i
=
0
,
exec
=
value
!==
undefined
&&
jQuery
.
isFunction
(
value
);
length
=
elems
.
length
;
// Sets many values
// Sets many values
if
(
key
&&
typeof
key
===
"object"
)
{
if
(
key
&&
typeof
key
===
"object"
)
{
chainable
=
true
;
for
(
i
in
key
)
{
for
(
i
in
key
)
{
jQuery
.
access
(
elems
,
fn
,
i
,
key
[
i
],
1
,
emptyGet
,
value
);
jQuery
.
access
(
elems
,
fn
,
i
,
key
[
i
],
true
,
emptyGet
);
}
}
chainable
=
1
;
// Sets one value
// Sets one value
}
else
if
(
value
!==
undefined
)
{
}
else
if
(
value
!==
undefined
)
{
// Optionally, function values get executed if exec is true
chainable
=
true
;
exec
=
pass
===
undefined
&&
jQuery
.
isFunction
(
value
);
if
(
bulk
)
{
if
(
bulk
)
{
// Bulk operations only iterate when executing function values
// Bulk operations only iterate when executing function values
...
@@ -802,12 +815,10 @@ jQuery.extend({
...
@@ -802,12 +815,10 @@ jQuery.extend({
}
}
if
(
fn
)
{
if
(
fn
)
{
for
(;
i
<
length
;
i
++
)
{
for
(
;
i
<
length
;
i
++
)
{
fn
(
elems
[
i
],
key
,
exec
?
value
.
call
(
elems
[
i
],
i
,
fn
(
elems
[
i
],
key
)
)
:
value
,
pass
);
fn
(
elems
[
i
],
key
,
exec
?
value
.
call
(
elems
[
i
],
i
,
fn
(
elems
[
i
],
key
)
)
:
value
);
}
}
}
}
chainable
=
1
;
}
}
return
chainable
?
return
chainable
?
...
...
test/unit/attributes.js
View file @
80d45a69
...
@@ -435,84 +435,6 @@ test( "attr(String, Object)", function() {
...
@@ -435,84 +435,6 @@ test( "attr(String, Object)", function() {
equal
(
jQuery
(
"#name"
).
attr
(
"nonexisting"
,
undefined
).
attr
(
"nonexisting"
),
undefined
,
".attr('attribute', undefined) does not create attribute (#5571)"
);
equal
(
jQuery
(
"#name"
).
attr
(
"nonexisting"
,
undefined
).
attr
(
"nonexisting"
),
undefined
,
".attr('attribute', undefined) does not create attribute (#5571)"
);
});
});
test
(
"attr(jquery_method)"
,
function
()
{
var
$elem
=
jQuery
(
"<div />"
),
elem
=
$elem
[
0
],
expected
=
2
,
attrObj
=
{};
if
(
jQuery
.
fn
.
width
)
{
expected
+=
2
;
attrObj
[
"width"
]
=
10
;
}
if
(
jQuery
.
fn
.
offset
)
{
expected
+=
2
;
attrObj
[
"offset"
]
=
{
"top"
:
1
,
"left"
:
0
};
}
if
(
jQuery
.
css
)
{
expected
+=
3
;
attrObj
[
"css"
]
=
{
"paddingLeft"
:
1
,
"paddingRight"
:
1
};
}
expect
(
expected
);
// one at a time
$elem
.
attr
({
"html"
:
"foo"
},
true
);
equal
(
elem
.
innerHTML
,
"foo"
,
"attr(html)"
);
$elem
.
attr
({
"text"
:
"bar"
},
true
);
equal
(
elem
.
innerHTML
,
"bar"
,
"attr(text)"
);
// Multiple attributes
$elem
.
attr
(
attrObj
,
true
);
if
(
jQuery
.
fn
.
width
)
{
equal
(
elem
.
style
.
width
,
"10px"
,
"attr({width:})"
);
$elem
.
attr
(
{
"height"
:
10
},
true
);
equal
(
elem
.
style
.
height
,
"10px"
,
"attr(height)"
);
}
if
(
jQuery
.
fn
.
offset
)
{
equal
(
elem
.
style
.
top
,
"1px"
,
"attr({offset:})"
);
$elem
.
attr
({
offset
:
{
top
:
1
,
left
:
1
}
},
true
);
equal
(
elem
.
style
.
left
,
"1px"
,
"attr(offset)"
);
}
if
(
jQuery
.
css
)
{
equal
(
elem
.
style
.
paddingLeft
,
"1px"
,
"attr({css:})"
);
equal
(
elem
.
style
.
paddingRight
,
"1px"
,
"attr({css:})"
);
$elem
.
attr
({
"css"
:
{
"color"
:
"red"
}
},
true
);
ok
(
/^
(
#ff0000|red
)
$/i
.
test
(
elem
.
style
.
color
),
"attr(css)"
);
}
});
test
(
"attr(String, Object) - Loaded via XML document"
,
function
()
{
test
(
"attr(String, Object) - Loaded via XML document"
,
function
()
{
expect
(
2
);
expect
(
2
);
var
xml
=
createDashboardXML
();
var
xml
=
createDashboardXML
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment