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
37902e86
Commit
37902e86
authored
Nov 30, 2007
by
David Serduke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a problem with changeset [3841] where a function could no longer be .extend()-ed.
parent
aca1cc36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
core.js
src/core.js
+1
-1
core.js
test/unit/core.js
+9
-1
No files found.
src/core.js
View file @
37902e86
...
...
@@ -530,7 +530,7 @@ jQuery.extend = jQuery.fn.extend = function() {
}
// Handle case when target is a string or something (possible in deep copy)
if
(
typeof
target
!=
"object"
)
if
(
typeof
target
!=
"object"
&&
typeof
target
!=
"function"
)
target
=
{};
// extend jQuery itself if only one argument is passed
...
...
test/unit/core.js
View file @
37902e86
...
...
@@ -837,7 +837,7 @@ test("is(String)", function() {
});
test
(
"$.extend(Object, Object)"
,
function
()
{
expect
(
1
5
);
expect
(
1
7
);
var
settings
=
{
xnumber1
:
5
,
xnumber2
:
7
,
xstring1
:
"peter"
,
xstring2
:
"pan"
},
options
=
{
xnumber2
:
1
,
xstring2
:
"x"
,
xxx
:
"newstring"
},
...
...
@@ -876,6 +876,14 @@ test("$.extend(Object, Object)", function() {
var
ret
=
jQuery
.
extend
(
true
,
{
foo
:
"bar"
},
{
foo
:
null
}
);
ok
(
typeof
ret
.
foo
!==
'undefined'
,
"Make sure a null value doesn't crash with deep extend, for #1908"
);
var
obj
=
{
foo
:
null
};
jQuery
.
extend
(
true
,
obj
,
{
foo
:
"notnull"
}
);
equals
(
obj
.
foo
,
"notnull"
,
"Make sure a null value can be overwritten"
);
function
func
()
{}
jQuery
.
extend
(
func
,
{
key
:
"value"
}
);
equals
(
func
.
key
,
"value"
,
"Verify a function can be extended"
);
var
defaults
=
{
xnumber1
:
5
,
xnumber2
:
7
,
xstring1
:
"peter"
,
xstring2
:
"pan"
},
defaultsCopy
=
{
xnumber1
:
5
,
xnumber2
:
7
,
xstring1
:
"peter"
,
xstring2
:
"pan"
},
options1
=
{
xnumber2
:
1
,
xstring2
:
"x"
},
...
...
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