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
f843a706
Commit
f843a706
authored
Jul 10, 2012
by
Uri Gilad
Committed by
Dave Methvin
Jul 10, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #10517. before() and after() on disconnected node should return multiple nodes. Closes gh-851.
parent
b6cb4b42
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
manipulation.js
src/manipulation.js
+3
-3
manipulation.js
test/unit/manipulation.js
+7
-0
No files found.
src/manipulation.js
View file @
f843a706
...
...
@@ -142,7 +142,7 @@ jQuery.fn.extend({
},
before
:
function
()
{
if
(
this
[
0
]
&&
this
[
0
].
parentNode
)
{
if
(
!
isDisconnected
(
this
[
0
]
)
)
{
return
this
.
domManip
(
arguments
,
false
,
function
(
elem
)
{
this
.
parentNode
.
insertBefore
(
elem
,
this
);
});
...
...
@@ -155,7 +155,7 @@ jQuery.fn.extend({
},
after
:
function
()
{
if
(
this
[
0
]
&&
this
[
0
].
parentNode
)
{
if
(
!
isDisconnected
(
this
[
0
]
)
)
{
return
this
.
domManip
(
arguments
,
false
,
function
(
elem
)
{
this
.
parentNode
.
insertBefore
(
elem
,
this
.
nextSibling
);
});
...
...
@@ -259,7 +259,7 @@ jQuery.fn.extend({
},
replaceWith
:
function
(
value
)
{
if
(
this
[
0
]
&&
this
[
0
].
parentNode
&&
this
[
0
].
parentNode
.
nodeType
!=
11
)
{
if
(
!
isDisconnected
(
this
[
0
]
)
)
{
// Make sure that the elements are removed from the DOM before they are inserted
// this can help fix replacing a parent with child elements
if
(
jQuery
.
isFunction
(
value
)
)
{
...
...
test/unit/manipulation.js
View file @
f843a706
...
...
@@ -917,6 +917,13 @@ test("before and after w/ empty object (#10812)", function() {
equal
(
res
.
wrapAll
(
"<div/>"
).
parent
().
text
(),
"()"
,
"correctly appended text"
);
});
test
(
"before and after on disconnected node (#10517)"
,
function
()
{
expect
(
2
);
equal
(
jQuery
(
"<input type='checkbox'/>"
).
before
(
"<div/>"
).
length
,
2
,
"before() returned all elements"
);
equal
(
jQuery
(
"<input type='checkbox'/>"
).
after
(
"<div/>"
).
length
,
2
,
"after() returned all elements"
);
});
test
(
"insertBefore(String|Element|Array<Element>|jQuery)"
,
function
()
{
expect
(
4
);
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