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
5c82d36f
Commit
5c82d36f
authored
Mar 06, 2013
by
Rick Waldron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert
8d1c4229
parent
8d1c4229
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
49 deletions
+5
-49
core.js
src/core.js
+3
-8
core.js
test/unit/core.js
+2
-41
No files found.
src/core.js
View file @
5c82d36f
...
@@ -422,11 +422,8 @@ jQuery.extend({
...
@@ -422,11 +422,8 @@ jQuery.extend({
},
},
isPlainObject
:
function
(
obj
)
{
isPlainObject
:
function
(
obj
)
{
var
key
;
// Not plain objects:
// Not plain objects:
// - Any object or value whose internal [[Class]] property is not "[object Object]"
// - Any object or value whose internal [[Class]] property is not "[object Object]"
// ...Unless it was a constructor, whose prototype property was paved over by
// by a plain object at its declaration. #13571
// - DOM nodes
// - DOM nodes
// - window
// - window
if
(
jQuery
.
type
(
obj
)
!==
"object"
||
obj
.
nodeType
||
jQuery
.
isWindow
(
obj
)
)
{
if
(
jQuery
.
type
(
obj
)
!==
"object"
||
obj
.
nodeType
||
jQuery
.
isWindow
(
obj
)
)
{
...
@@ -445,11 +442,9 @@ jQuery.extend({
...
@@ -445,11 +442,9 @@ jQuery.extend({
return
false
;
return
false
;
}
}
// Own properties are enumerated firstly, so to speed up,
// If the function hasn't returned already, we're confident that
// if last one is own, then all properties are own.
// |obj| is a plain object, created by {} or constructed with new Object
for
(
key
in
obj
)
{}
return
true
;
return
key
===
undefined
||
core_hasOwn
.
call
(
obj
,
key
);
},
},
isEmptyObject
:
function
(
obj
)
{
isEmptyObject
:
function
(
obj
)
{
...
...
test/unit/core.js
View file @
5c82d36f
...
@@ -296,9 +296,9 @@ test("type", function() {
...
@@ -296,9 +296,9 @@ test("type", function() {
});
});
asyncTest
(
"isPlainObject"
,
function
()
{
asyncTest
(
"isPlainObject"
,
function
()
{
expect
(
1
6
);
expect
(
1
5
);
var
pass
,
iframe
,
doc
,
c
,
extended
,
var
pass
,
iframe
,
doc
,
fn
=
function
()
{};
fn
=
function
()
{};
// The use case that we want to match
// The use case that we want to match
...
@@ -360,45 +360,6 @@ asyncTest("isPlainObject", function() {
...
@@ -360,45 +360,6 @@ asyncTest("isPlainObject", function() {
}
catch
(
e
)
{
}
catch
(
e
)
{
window
.
iframeDone
(
Object
,
"iframes not supported"
);
window
.
iframeDone
(
Object
,
"iframes not supported"
);
}
}
// #13571
function
C
()
{}
C
.
prototype
=
{
x
:
1
};
c
=
new
C
();
extended
=
jQuery
.
extend
(
true
,
{},
{
target
:
c
});
strictEqual
(
extended
.
target
,
c
,
"Instances, whose constructor defined its prototype by assigning a plain object, "
+
"will lie about their true identity to preserve a broken user-code expectation"
);
//
// The test above is broken and tests a broken feature, to support a misinformed
// assumption, as documented here:
//
// http://bugs.jquery.com/ticket/13571#comment:4
//
// It will not pass if the object being assigned as the prototype
// has no properties:
//
// function C() {}
// C.prototype = {};
// c = new C();
// extended = jQuery.extend( true, {}, {
// target: c
// });
// strictEqual( extended.target, c, "Undetectable, will fail every time" );
//
// The solution is to reset the constructor property of your plain object prototypes.
//
//
});
});
test
(
"isFunction"
,
function
()
{
test
(
"isFunction"
,
function
()
{
...
...
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