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
cdd5132d
Commit
cdd5132d
authored
Jul 05, 2012
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12026. Let props in $(html, props) be any jQuery.fn method.
Closes gh-839.
parent
1e027610
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
16 deletions
+13
-16
attributes.js
src/attributes.js
+1
-12
core.js
test/unit/core.js
+12
-4
No files found.
src/attributes.js
View file @
cdd5132d
...
@@ -281,17 +281,6 @@ jQuery.extend({
...
@@ -281,17 +281,6 @@ jQuery.extend({
}
}
},
},
attrFn
:
{
val
:
true
,
css
:
true
,
html
:
true
,
text
:
true
,
data
:
true
,
width
:
true
,
height
:
true
,
offset
:
true
},
attr
:
function
(
elem
,
name
,
value
,
pass
)
{
attr
:
function
(
elem
,
name
,
value
,
pass
)
{
var
ret
,
hooks
,
notxml
,
var
ret
,
hooks
,
notxml
,
nType
=
elem
.
nodeType
;
nType
=
elem
.
nodeType
;
...
@@ -301,7 +290,7 @@ jQuery.extend({
...
@@ -301,7 +290,7 @@ jQuery.extend({
return
;
return
;
}
}
if
(
pass
&&
name
in
jQuery
.
attrFn
)
{
if
(
pass
&&
jQuery
.
isFunction
(
jQuery
.
fn
[
name
]
)
)
{
return
jQuery
(
elem
)[
name
](
value
);
return
jQuery
(
elem
)[
name
](
value
);
}
}
...
...
test/unit/core.js
View file @
cdd5132d
...
@@ -35,20 +35,24 @@ test("jQuery()", function() {
...
@@ -35,20 +35,24 @@ test("jQuery()", function() {
"id"
:
"test3"
"id"
:
"test3"
};
};
// The $(html, props) signature can stealth-call any $.fn method, check for a
// few here but beware of modular builds where these methods may be excluded.
if
(
jQuery
.
fn
.
width
)
{
if
(
jQuery
.
fn
.
width
)
{
expected
++
;
expected
++
;
attrObj
[
"width"
]
=
10
;
attrObj
[
"width"
]
=
10
;
}
}
if
(
jQuery
.
fn
.
offset
)
{
if
(
jQuery
.
fn
.
offset
)
{
expected
++
;
expected
++
;
attrObj
[
"offset"
]
=
{
"top"
:
1
,
"left"
:
1
};
attrObj
[
"offset"
]
=
{
"top"
:
1
,
"left"
:
1
};
}
}
if
(
jQuery
.
fn
.
css
)
{
if
(
jQuery
.
css
)
{
expected
+=
2
;
expected
+=
2
;
attrObj
[
"css"
]
=
{
"paddingLeft"
:
1
,
"paddingRight"
:
1
};
attrObj
[
"css"
]
=
{
"paddingLeft"
:
1
,
"paddingRight"
:
1
};
}
}
if
(
jQuery
.
fn
.
attr
)
{
expected
++
;
attrObj
.
attr
=
{
"desired"
:
"very"
};
}
expect
(
expected
);
expect
(
expected
);
...
@@ -107,11 +111,15 @@ test("jQuery()", function() {
...
@@ -107,11 +111,15 @@ test("jQuery()", function() {
equal
(
elem
[
0
].
style
.
top
,
"1px"
,
"jQuery() quick setter offset"
);
equal
(
elem
[
0
].
style
.
top
,
"1px"
,
"jQuery() quick setter offset"
);
}
}
if
(
jQuery
.
css
)
{
if
(
jQuery
.
fn
.
css
)
{
equal
(
elem
[
0
].
style
.
paddingLeft
,
"1px"
,
"jQuery quick setter css"
);
equal
(
elem
[
0
].
style
.
paddingLeft
,
"1px"
,
"jQuery quick setter css"
);
equal
(
elem
[
0
].
style
.
paddingRight
,
"1px"
,
"jQuery quick setter css"
);
equal
(
elem
[
0
].
style
.
paddingRight
,
"1px"
,
"jQuery quick setter css"
);
}
}
if
(
jQuery
.
fn
.
attr
)
{
equal
(
elem
[
0
].
getAttribute
(
"desired"
),
"very"
,
"jQuery quick setter attr"
);
}
equal
(
elem
[
0
].
childNodes
.
length
,
1
,
"jQuery quick setter text"
);
equal
(
elem
[
0
].
childNodes
.
length
,
1
,
"jQuery quick setter text"
);
equal
(
elem
[
0
].
firstChild
.
nodeValue
,
"test"
,
"jQuery quick setter text"
);
equal
(
elem
[
0
].
firstChild
.
nodeValue
,
"test"
,
"jQuery quick setter text"
);
equal
(
elem
[
0
].
className
,
"test2"
,
"jQuery() quick setter class"
);
equal
(
elem
[
0
].
className
,
"test2"
,
"jQuery() quick setter class"
);
...
...
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