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
726fda08
Commit
726fda08
authored
Feb 13, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure the fragment isn't used if it's not the same set we're working with. Fixes #6068.
parent
a7dc66b8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
manipulation.js
src/manipulation.js
+9
-5
manipulation.js
test/unit/manipulation.js
+6
-1
No files found.
src/manipulation.js
View file @
726fda08
...
@@ -300,7 +300,7 @@ jQuery.fn.extend({
...
@@ -300,7 +300,7 @@ jQuery.fn.extend({
},
},
domManip
:
function
(
args
,
table
,
callback
)
{
domManip
:
function
(
args
,
table
,
callback
)
{
var
results
,
first
,
value
=
args
[
0
],
scripts
=
[],
fragment
;
var
results
,
first
,
value
=
args
[
0
],
scripts
=
[],
fragment
,
parent
;
// We can't cloneNode fragments that contain checked, in WebKit
// We can't cloneNode fragments that contain checked, in WebKit
if
(
!
jQuery
.
support
.
checkClone
&&
arguments
.
length
===
3
&&
typeof
value
===
"string"
&&
rchecked
.
test
(
value
)
)
{
if
(
!
jQuery
.
support
.
checkClone
&&
arguments
.
length
===
3
&&
typeof
value
===
"string"
&&
rchecked
.
test
(
value
)
)
{
...
@@ -318,9 +318,12 @@ jQuery.fn.extend({
...
@@ -318,9 +318,12 @@ jQuery.fn.extend({
}
}
if
(
this
[
0
]
)
{
if
(
this
[
0
]
)
{
parent
=
value
&&
value
.
parentNode
;
// If we're in a fragment, just use that instead of building a new one
// If we're in a fragment, just use that instead of building a new one
if
(
args
[
0
]
&&
args
[
0
].
parentNode
&&
args
[
0
].
parentNode
.
nodeType
===
11
)
{
if
(
parent
&&
parent
.
nodeType
===
11
&&
parent
.
childNodes
.
length
===
this
.
length
)
{
results
=
{
fragment
:
args
[
0
].
parentNode
};
results
=
{
fragment
:
parent
};
}
else
{
}
else
{
results
=
buildFragment
(
args
,
this
,
scripts
);
results
=
buildFragment
(
args
,
this
,
scripts
);
}
}
...
@@ -429,9 +432,10 @@ jQuery.each({
...
@@ -429,9 +432,10 @@ jQuery.each({
replaceAll
:
"replaceWith"
replaceAll
:
"replaceWith"
},
function
(
name
,
original
)
{
},
function
(
name
,
original
)
{
jQuery
.
fn
[
name
]
=
function
(
selector
)
{
jQuery
.
fn
[
name
]
=
function
(
selector
)
{
var
ret
=
[],
insert
=
jQuery
(
selector
);
var
ret
=
[],
insert
=
jQuery
(
selector
),
parent
=
this
.
length
===
1
&&
this
[
0
].
parentNode
;
if
(
this
.
length
===
1
&&
this
[
0
].
parentNode
&&
this
[
0
].
parentNode
.
nodeType
===
1
1
&&
insert
.
length
===
1
)
{
if
(
parent
&&
parent
.
nodeType
===
11
&&
parent
.
childNodes
.
length
===
1
&&
insert
.
length
===
1
)
{
insert
[
original
](
this
[
0
]
);
insert
[
original
](
this
[
0
]
);
return
this
;
return
this
;
...
...
test/unit/manipulation.js
View file @
726fda08
...
@@ -376,7 +376,7 @@ test("append(Function) with incoming value", function() {
...
@@ -376,7 +376,7 @@ test("append(Function) with incoming value", function() {
});
});
test
(
"appendTo(String|Element|Array<Element>|jQuery)"
,
function
()
{
test
(
"appendTo(String|Element|Array<Element>|jQuery)"
,
function
()
{
expect
(
1
2
);
expect
(
1
3
);
var
defaultText
=
'Try them out:'
var
defaultText
=
'Try them out:'
jQuery
(
'<b>buga</b>'
).
appendTo
(
'#first'
);
jQuery
(
'<b>buga</b>'
).
appendTo
(
'#first'
);
equals
(
jQuery
(
"#first"
).
text
(),
defaultText
+
'buga'
,
'Check if text appending works'
);
equals
(
jQuery
(
"#first"
).
text
(),
defaultText
+
'buga'
,
'Check if text appending works'
);
...
@@ -424,6 +424,11 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
...
@@ -424,6 +424,11 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
ok
(
jQuery
(
"#moretests div:last"
).
hasClass
(
"test"
),
"appendTo element was modified after the insertion"
);
ok
(
jQuery
(
"#moretests div:last"
).
hasClass
(
"test"
),
"appendTo element was modified after the insertion"
);
reset
();
reset
();
div
=
jQuery
(
"<div/>"
);
jQuery
(
"<span>a</span><b>b</b>"
).
filter
(
"span"
).
appendTo
(
div
);
equals
(
div
.
children
().
length
,
1
,
"Make sure the right number of children were inserted."
);
});
});
var
testPrepend
=
function
(
val
)
{
var
testPrepend
=
function
(
val
)
{
...
...
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