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
21b0db79
Commit
21b0db79
authored
Jul 10, 2012
by
Uri Gilad
Committed by
Dave Methvin
Jul 10, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #11962. Standardize getter return values for empty sets.
parent
376f4e8c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
3 deletions
+14
-3
manipulation.js
src/manipulation.js
+1
-1
offset.js
src/offset.js
+2
-2
manipulation.js
test/unit/manipulation.js
+5
-0
offset.js
test/unit/offset.js
+6
-0
No files found.
src/manipulation.js
View file @
21b0db79
...
@@ -225,7 +225,7 @@ jQuery.fn.extend({
...
@@ -225,7 +225,7 @@ jQuery.fn.extend({
if
(
value
===
undefined
)
{
if
(
value
===
undefined
)
{
return
elem
.
nodeType
===
1
?
return
elem
.
nodeType
===
1
?
elem
.
innerHTML
.
replace
(
rinlinejQuery
,
""
)
:
elem
.
innerHTML
.
replace
(
rinlinejQuery
,
""
)
:
null
;
undefined
;
}
}
// See if we can take a shortcut and just use innerHTML
// See if we can take a shortcut and just use innerHTML
...
...
src/offset.js
View file @
21b0db79
...
@@ -14,7 +14,7 @@ jQuery.fn.offset = function( options ) {
...
@@ -14,7 +14,7 @@ jQuery.fn.offset = function( options ) {
doc
=
elem
&&
elem
.
ownerDocument
;
doc
=
elem
&&
elem
.
ownerDocument
;
if
(
!
doc
)
{
if
(
!
doc
)
{
return
null
;
return
;
}
}
if
(
(
body
=
doc
.
body
)
===
elem
)
{
if
(
(
body
=
doc
.
body
)
===
elem
)
{
...
@@ -103,7 +103,7 @@ jQuery.fn.extend({
...
@@ -103,7 +103,7 @@ jQuery.fn.extend({
position
:
function
()
{
position
:
function
()
{
if
(
!
this
[
0
]
)
{
if
(
!
this
[
0
]
)
{
return
null
;
return
;
}
}
var
elem
=
this
[
0
],
var
elem
=
this
[
0
],
...
...
test/unit/manipulation.js
View file @
21b0db79
...
@@ -1351,6 +1351,11 @@ test("html(undefined)", function() {
...
@@ -1351,6 +1351,11 @@ test("html(undefined)", function() {
equal
(
jQuery
(
"#foo"
).
html
(
"<i>test</i>"
).
html
(
undefined
).
html
().
toLowerCase
(),
"<i>test</i>"
,
".html(undefined) is chainable (#5571)"
);
equal
(
jQuery
(
"#foo"
).
html
(
"<i>test</i>"
).
html
(
undefined
).
html
().
toLowerCase
(),
"<i>test</i>"
,
".html(undefined) is chainable (#5571)"
);
});
});
test
(
"html() on empty set"
,
function
()
{
expect
(
1
);
strictEqual
(
jQuery
(
).
html
(),
undefined
,
".html() returns undefined for empty sets (#11962)"
);
});
var
testHtml
=
function
(
valueObj
)
{
var
testHtml
=
function
(
valueObj
)
{
expect
(
35
);
expect
(
35
);
...
...
test/unit/offset.js
View file @
21b0db79
...
@@ -9,6 +9,12 @@ module("offset", { teardown: moduleTeardown });
...
@@ -9,6 +9,12 @@ module("offset", { teardown: moduleTeardown });
the iframe window and the "jQuery" symbol is used to access any static methods.
the iframe window and the "jQuery" symbol is used to access any static methods.
*/
*/
test
(
"empty set"
,
function
()
{
expect
(
2
);
strictEqual
(
jQuery
(
).
offset
(),
undefined
,
"offset() returns undefined for empty set (#11962)"
);
strictEqual
(
jQuery
(
).
position
(),
undefined
,
"position() returns undefined for empty set (#11962)"
);
});
test
(
"disconnected node"
,
function
()
{
test
(
"disconnected node"
,
function
()
{
expect
(
2
);
expect
(
2
);
...
...
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