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
58b8535d
Commit
58b8535d
authored
Apr 04, 2013
by
Brandon Johnson
Committed by
Dave Methvin
Apr 04, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12199. Handle iteration over inherited properties in oldIE. Close
gh-1196.
parent
df7847bc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
13 deletions
+48
-13
AUTHORS.txt
AUTHORS.txt
+1
-0
core.js
src/core.js
+10
-2
support.js
src/support.js
+7
-0
core.js
test/unit/core.js
+11
-1
support.js
test/unit/support.js
+19
-10
No files found.
AUTHORS.txt
View file @
58b8535d
...
@@ -162,3 +162,4 @@ Jean Boussier <jean.boussier@gmail.com>
...
@@ -162,3 +162,4 @@ Jean Boussier <jean.boussier@gmail.com>
Adam Coulombe <me@adam.co>
Adam Coulombe <me@adam.co>
Andrew Plummer <plummer.andrew@gmail.com>
Andrew Plummer <plummer.andrew@gmail.com>
Dmitry Gusev <dmitry.gusev@gmail.com>
Dmitry Gusev <dmitry.gusev@gmail.com>
Brandon Johnson <bjohn465+github@gmail.com>
src/core.js
View file @
58b8535d
...
@@ -453,6 +453,8 @@ jQuery.extend({
...
@@ -453,6 +453,8 @@ jQuery.extend({
},
},
isPlainObject
:
function
(
obj
)
{
isPlainObject
:
function
(
obj
)
{
var
key
;
// Must be an Object.
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
// Make sure that DOM nodes and window objects don't pass through, as well
...
@@ -472,10 +474,16 @@ jQuery.extend({
...
@@ -472,10 +474,16 @@ jQuery.extend({
return
false
;
return
false
;
}
}
// Support: IE<9
// Handle iteration over inherited properties before own properties.
if
(
jQuery
.
support
.
ownLast
)
{
for
(
key
in
obj
)
{
return
core_hasOwn
.
call
(
obj
,
key
);
}
}
// Own properties are enumerated firstly, so to speed up,
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
// if last one is own, then all properties are own.
var
key
;
for
(
key
in
obj
)
{}
for
(
key
in
obj
)
{}
return
key
===
undefined
||
core_hasOwn
.
call
(
obj
,
key
);
return
key
===
undefined
||
core_hasOwn
.
call
(
obj
,
key
);
...
...
src/support.js
View file @
58b8535d
...
@@ -141,6 +141,13 @@ jQuery.support = (function( support ) {
...
@@ -141,6 +141,13 @@ jQuery.support = (function( support ) {
div
.
cloneNode
(
true
).
style
.
backgroundClip
=
""
;
div
.
cloneNode
(
true
).
style
.
backgroundClip
=
""
;
support
.
clearCloneStyle
=
div
.
style
.
backgroundClip
===
"content-box"
;
support
.
clearCloneStyle
=
div
.
style
.
backgroundClip
===
"content-box"
;
// Support: IE<9
// Iteration over object's inherited properties before its own.
for
(
i
in
jQuery
(
support
)
)
{
break
;
}
support
.
ownLast
=
i
!==
"0"
;
// Run tests that need a body at doc ready
// Run tests that need a body at doc ready
jQuery
(
function
()
{
jQuery
(
function
()
{
var
container
,
marginDiv
,
tds
,
var
container
,
marginDiv
,
tds
,
...
...
test/unit/core.js
View file @
58b8535d
...
@@ -296,7 +296,7 @@ test("type", function() {
...
@@ -296,7 +296,7 @@ test("type", function() {
});
});
asyncTest
(
"isPlainObject"
,
function
()
{
asyncTest
(
"isPlainObject"
,
function
()
{
expect
(
1
5
);
expect
(
1
6
);
var
pass
,
iframe
,
doc
,
var
pass
,
iframe
,
doc
,
fn
=
function
()
{};
fn
=
function
()
{};
...
@@ -330,6 +330,16 @@ asyncTest("isPlainObject", function() {
...
@@ -330,6 +330,16 @@ asyncTest("isPlainObject", function() {
// Again, instantiated objects shouldn't be matched
// Again, instantiated objects shouldn't be matched
ok
(
!
jQuery
.
isPlainObject
(
new
fn
()),
"new fn"
);
ok
(
!
jQuery
.
isPlainObject
(
new
fn
()),
"new fn"
);
// Make it even harder to detect in IE < 9
fn
=
function
()
{
this
.
a
=
"a"
;
};
fn
.
prototype
=
{
b
:
"b"
};
ok
(
!
jQuery
.
isPlainObject
(
new
fn
()),
"fn (inherited and own properties)"
);
// DOM Element
// DOM Element
ok
(
!
jQuery
.
isPlainObject
(
document
.
createElement
(
"div"
)
),
"DOM Element"
);
ok
(
!
jQuery
.
isPlainObject
(
document
.
createElement
(
"div"
)
),
"DOM Element"
);
...
...
test/unit/support.js
View file @
58b8535d
...
@@ -80,7 +80,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -80,7 +80,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"reliableHiddenOffsets"
:
true
,
"reliableHiddenOffsets"
:
true
,
"ajax"
:
true
,
"ajax"
:
true
,
"cors"
:
true
,
"cors"
:
true
,
"clearCloneStyle"
:
true
"clearCloneStyle"
:
true
,
"ownLast"
:
false
};
};
}
else
if
(
/opera.*version
\/
12
\.
1/i
.
test
(
userAgent
)
)
{
}
else
if
(
/opera.*version
\/
12
\.
1/i
.
test
(
userAgent
)
)
{
expected
=
{
expected
=
{
...
@@ -113,7 +114,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -113,7 +114,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"reliableHiddenOffsets"
:
true
,
"reliableHiddenOffsets"
:
true
,
"ajax"
:
true
,
"ajax"
:
true
,
"cors"
:
true
,
"cors"
:
true
,
"clearCloneStyle"
:
true
"clearCloneStyle"
:
true
,
"ownLast"
:
false
};
};
}
else
if
(
/msie 10
\.
0/i
.
test
(
userAgent
)
)
{
}
else
if
(
/msie 10
\.
0/i
.
test
(
userAgent
)
)
{
expected
=
{
expected
=
{
...
@@ -146,7 +148,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -146,7 +148,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"reliableHiddenOffsets"
:
true
,
"reliableHiddenOffsets"
:
true
,
"ajax"
:
true
,
"ajax"
:
true
,
"cors"
:
true
,
"cors"
:
true
,
"clearCloneStyle"
:
false
"clearCloneStyle"
:
false
,
"ownLast"
:
false
};
};
}
else
if
(
/msie 9
\.
0/i
.
test
(
userAgent
)
)
{
}
else
if
(
/msie 9
\.
0/i
.
test
(
userAgent
)
)
{
expected
=
{
expected
=
{
...
@@ -179,7 +182,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -179,7 +182,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"reliableHiddenOffsets"
:
true
,
"reliableHiddenOffsets"
:
true
,
"ajax"
:
true
,
"ajax"
:
true
,
"cors"
:
false
,
"cors"
:
false
,
"clearCloneStyle"
:
false
"clearCloneStyle"
:
false
,
"ownLast"
:
false
};
};
}
else
if
(
/msie 8
\.
0/i
.
test
(
userAgent
)
)
{
}
else
if
(
/msie 8
\.
0/i
.
test
(
userAgent
)
)
{
expected
=
{
expected
=
{
...
@@ -212,7 +216,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -212,7 +216,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"reliableHiddenOffsets"
:
false
,
"reliableHiddenOffsets"
:
false
,
"ajax"
:
true
,
"ajax"
:
true
,
"cors"
:
false
,
"cors"
:
false
,
"clearCloneStyle"
:
true
"clearCloneStyle"
:
true
,
"ownLast"
:
true
};
};
}
else
if
(
/msie 7
\.
0/i
.
test
(
userAgent
)
)
{
}
else
if
(
/msie 7
\.
0/i
.
test
(
userAgent
)
)
{
expected
=
{
expected
=
{
...
@@ -245,7 +250,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -245,7 +250,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"submitBubbles"
:
false
,
"submitBubbles"
:
false
,
"tbody"
:
false
,
"tbody"
:
false
,
"style"
:
false
,
"style"
:
false
,
"clearCloneStyle"
:
true
"clearCloneStyle"
:
true
,
"ownLast"
:
true
};
};
}
else
if
(
/msie 6
\.
0/i
.
test
(
userAgent
)
)
{
}
else
if
(
/msie 6
\.
0/i
.
test
(
userAgent
)
)
{
expected
=
{
expected
=
{
...
@@ -278,7 +284,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -278,7 +284,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"reliableHiddenOffsets"
:
false
,
"reliableHiddenOffsets"
:
false
,
"ajax"
:
true
,
"ajax"
:
true
,
"cors"
:
false
,
"cors"
:
false
,
"clearCloneStyle"
:
true
"clearCloneStyle"
:
true
,
"ownLast"
:
true
};
};
}
else
if
(
/5
\.
1
\.
1 safari/i
.
test
(
userAgent
)
)
{
}
else
if
(
/5
\.
1
\.
1 safari/i
.
test
(
userAgent
)
)
{
expected
=
{
expected
=
{
...
@@ -311,7 +318,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -311,7 +318,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"reliableHiddenOffsets"
:
true
,
"reliableHiddenOffsets"
:
true
,
"ajax"
:
true
,
"ajax"
:
true
,
"cors"
:
true
,
"cors"
:
true
,
"clearCloneStyle"
:
true
"clearCloneStyle"
:
true
,
"ownLast"
:
false
};
};
}
else
if
(
/firefox/i
.
test
(
userAgent
)
)
{
}
else
if
(
/firefox/i
.
test
(
userAgent
)
)
{
expected
=
{
expected
=
{
...
@@ -344,13 +352,14 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -344,13 +352,14 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"reliableHiddenOffsets"
:
true
,
"reliableHiddenOffsets"
:
true
,
"ajax"
:
true
,
"ajax"
:
true
,
"cors"
:
true
,
"cors"
:
true
,
"clearCloneStyle"
:
true
"clearCloneStyle"
:
true
,
"ownLast"
:
false
};
};
}
}
if
(
expected
)
{
if
(
expected
)
{
test
(
"Verify that the support tests resolve as expected per browser"
,
function
()
{
test
(
"Verify that the support tests resolve as expected per browser"
,
function
()
{
expect
(
3
0
);
expect
(
3
1
);
for
(
var
i
in
expected
)
{
for
(
var
i
in
expected
)
{
if
(
jQuery
.
ajax
||
i
!==
"ajax"
&&
i
!==
"cors"
)
{
if
(
jQuery
.
ajax
||
i
!==
"ajax"
&&
i
!==
"cors"
)
{
...
...
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