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
fc563cc4
Commit
fc563cc4
authored
Nov 09, 2010
by
rwldrn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #7413; isEmptyObject() check to see if obj passes isPlainObject
parent
a64dc040
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
core.js
src/core.js
+6
-0
core.js
test/unit/core.js
+11
-4
No files found.
src/core.js
View file @
fc563cc4
...
...
@@ -532,6 +532,12 @@ jQuery.extend({
},
isEmptyObject
:
function
(
obj
)
{
// Fixes #7413 Check to see if obj passes isPlainObject
if
(
!
jQuery
.
isPlainObject
(
obj
)
)
{
return
false
;
}
for
(
var
name
in
obj
)
{
return
false
;
}
...
...
test/unit/core.js
View file @
fc563cc4
...
...
@@ -848,13 +848,20 @@ test("jQuery.makeArray", function(){
});
test
(
"jQuery.isEmptyObject"
,
function
(){
expect
(
2
);
expect
(
11
);
equals
(
true
,
jQuery
.
isEmptyObject
({}),
"isEmptyObject on empty object literal"
);
equals
(
false
,
jQuery
.
isEmptyObject
({
a
:
1
}),
"isEmptyObject on non-empty object literal"
);
// What about this ?
// equals(true, jQuery.isEmptyObject(null), "isEmptyObject on null" );
equals
(
false
,
jQuery
.
isEmptyObject
(
1
),
"isEmptyObject on number (wrong argument type)"
);
equals
(
false
,
jQuery
.
isEmptyObject
(
0
),
"isEmptyObject on falsy number (wrong argument type)"
);
equals
(
false
,
jQuery
.
isEmptyObject
(
"test"
),
"isEmptyObject on string (wrong argument type)"
);
equals
(
false
,
jQuery
.
isEmptyObject
(
""
),
"isEmptyObject on falsy string (wrong argument type)"
);
equals
(
false
,
jQuery
.
isEmptyObject
([
1
,
2
,
3
]),
"isEmptyObject on array (wrong argument type)"
);
equals
(
false
,
jQuery
.
isEmptyObject
([]),
"isEmptyObject on an empty array (wrong argument type)"
);
equals
(
false
,
jQuery
.
isEmptyObject
(
undefined
),
"isEmptyObject on undefined (wrong argument type)"
);
equals
(
false
,
jQuery
.
isEmptyObject
(
false
),
"isEmptyObject on undefined (wrong argument type)"
);
equals
(
false
,
jQuery
.
isEmptyObject
(
null
),
"isEmptyObject on null (wrong argument type)"
);
});
test
(
"jQuery.proxy"
,
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