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
dd845a2c
Commit
dd845a2c
authored
Nov 17, 2011
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #10812, let .before() and .after() work on empty collections.
parent
7c2d6c8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
manipulation.js
src/manipulation.js
+2
-2
manipulation.js
test/unit/manipulation.js
+8
-0
No files found.
src/manipulation.js
View file @
dd845a2c
...
@@ -154,7 +154,7 @@ jQuery.fn.extend({
...
@@ -154,7 +154,7 @@ jQuery.fn.extend({
this
.
parentNode
.
insertBefore
(
elem
,
this
);
this
.
parentNode
.
insertBefore
(
elem
,
this
);
});
});
}
else
if
(
arguments
.
length
)
{
}
else
if
(
arguments
.
length
)
{
var
set
=
jQuery
(
arguments
[
0
]
);
var
set
=
jQuery
.
clean
(
arguments
);
set
.
push
.
apply
(
set
,
this
.
toArray
()
);
set
.
push
.
apply
(
set
,
this
.
toArray
()
);
return
this
.
pushStack
(
set
,
"before"
,
arguments
);
return
this
.
pushStack
(
set
,
"before"
,
arguments
);
}
}
...
@@ -167,7 +167,7 @@ jQuery.fn.extend({
...
@@ -167,7 +167,7 @@ jQuery.fn.extend({
});
});
}
else
if
(
arguments
.
length
)
{
}
else
if
(
arguments
.
length
)
{
var
set
=
this
.
pushStack
(
this
,
"after"
,
arguments
);
var
set
=
this
.
pushStack
(
this
,
"after"
,
arguments
);
set
.
push
.
apply
(
set
,
jQuery
(
arguments
[
0
]).
toArray
(
)
);
set
.
push
.
apply
(
set
,
jQuery
.
clean
(
arguments
)
);
return
set
;
return
set
;
}
}
},
},
...
...
test/unit/manipulation.js
View file @
dd845a2c
...
@@ -794,6 +794,14 @@ test("before(Function)", function() {
...
@@ -794,6 +794,14 @@ test("before(Function)", function() {
testBefore
(
functionReturningObj
);
testBefore
(
functionReturningObj
);
})
})
test
(
"before and after w/ empty object (#10812)"
,
function
()
{
expect
(
2
);
var
res
=
jQuery
(
"#notInTheDocument"
).
before
(
"("
).
after
(
")"
);
equal
(
res
.
length
,
2
,
"didn't choke on empty object"
);
equal
(
res
.
wrap
(
"<div/>"
).
parent
().
text
(),
"()"
,
"correctly appended text"
);
});
test
(
"insertBefore(String|Element|Array<Element>|jQuery)"
,
function
()
{
test
(
"insertBefore(String|Element|Array<Element>|jQuery)"
,
function
()
{
expect
(
4
);
expect
(
4
);
var
expected
=
"This is a normal link: bugaYahoo"
;
var
expected
=
"This is a normal link: bugaYahoo"
;
...
...
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