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
8e6c1ba9
Commit
8e6c1ba9
authored
Jan 09, 2013
by
Oleg
Committed by
Richard Gibson
Jan 09, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ref gh-1117: Don't stop on a falsy value in buildFragment. Close gh-1124.
parent
2f6b3f81
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
manipulation.js
src/manipulation.js
+8
-3
manipulation.js
test/unit/manipulation.js
+2
-2
No files found.
src/manipulation.js
View file @
8e6c1ba9
...
@@ -424,10 +424,14 @@ jQuery.extend({
...
@@ -424,10 +424,14 @@ jQuery.extend({
buildFragment
:
function
(
elems
,
context
,
scripts
,
selection
)
{
buildFragment
:
function
(
elems
,
context
,
scripts
,
selection
)
{
var
elem
,
tmp
,
tag
,
wrap
,
contains
,
j
,
var
elem
,
tmp
,
tag
,
wrap
,
contains
,
j
,
i
=
0
,
i
=
0
,
l
=
elems
.
length
,
fragment
=
context
.
createDocumentFragment
(),
fragment
=
context
.
createDocumentFragment
(),
nodes
=
[];
nodes
=
[];
while
(
(
elem
=
elems
[
i
++
]
)
||
elem
===
0
)
{
for
(
;
i
<
l
;
i
++
)
{
elem
=
elems
[
i
];
if
(
elem
||
elem
===
0
)
{
// Add nodes directly
// Add nodes directly
if
(
jQuery
.
type
(
elem
)
===
"object"
)
{
if
(
jQuery
.
type
(
elem
)
===
"object"
)
{
...
@@ -462,13 +466,13 @@ jQuery.extend({
...
@@ -462,13 +466,13 @@ jQuery.extend({
tmp
.
textContent
=
""
;
tmp
.
textContent
=
""
;
}
}
}
}
}
// Remove wrapper from fragment
// Remove wrapper from fragment
fragment
.
textContent
=
""
;
fragment
.
textContent
=
""
;
i
=
0
;
i
=
0
;
while
(
(
elem
=
nodes
[
i
++
])
)
{
while
(
(
elem
=
nodes
[
i
++
])
)
{
contains
=
jQuery
.
contains
(
elem
.
ownerDocument
,
elem
);
// #4087 - If origin and destination elements are the same, and this is
// #4087 - If origin and destination elements are the same, and this is
// that element, do not do anything
// that element, do not do anything
...
@@ -476,6 +480,8 @@ jQuery.extend({
...
@@ -476,6 +480,8 @@ jQuery.extend({
continue
;
continue
;
}
}
contains
=
jQuery
.
contains
(
elem
.
ownerDocument
,
elem
);
// Append to fragment
// Append to fragment
tmp
=
getAll
(
fragment
.
appendChild
(
elem
),
"script"
);
tmp
=
getAll
(
fragment
.
appendChild
(
elem
),
"script"
);
...
@@ -486,7 +492,6 @@ jQuery.extend({
...
@@ -486,7 +492,6 @@ jQuery.extend({
// Capture executables
// Capture executables
if
(
scripts
)
{
if
(
scripts
)
{
j
=
0
;
j
=
0
;
while
(
(
elem
=
tmp
[
j
++
])
)
{
while
(
(
elem
=
tmp
[
j
++
])
)
{
if
(
rscriptType
.
test
(
elem
.
type
||
""
)
)
{
if
(
rscriptType
.
test
(
elem
.
type
||
""
)
)
{
...
...
test/unit/manipulation.js
View file @
8e6c1ba9
...
@@ -395,7 +395,7 @@ var testAppendForObject = function( valueObj, isFragment ) {
...
@@ -395,7 +395,7 @@ var testAppendForObject = function( valueObj, isFragment ) {
var
testAppend
=
function
(
valueObj
)
{
var
testAppend
=
function
(
valueObj
)
{
expect
(
7
7
);
expect
(
7
8
);
testAppendForObject
(
valueObj
,
false
);
testAppendForObject
(
valueObj
,
false
);
testAppendForObject
(
valueObj
,
true
);
testAppendForObject
(
valueObj
,
true
);
...
@@ -469,13 +469,13 @@ var testAppend = function( valueObj ) {
...
@@ -469,13 +469,13 @@ var testAppend = function( valueObj ) {
jQuery
(
"#table colgroup"
).
append
(
valueObj
(
"<col/>"
)
);
jQuery
(
"#table colgroup"
).
append
(
valueObj
(
"<col/>"
)
);
equal
(
jQuery
(
"#table colgroup col"
).
length
,
1
,
"Append col"
);
equal
(
jQuery
(
"#table colgroup col"
).
length
,
1
,
"Append col"
);
jQuery
(
"#form"
)
jQuery
(
"#form"
)
.
append
(
valueObj
(
"<select id='appendSelect1'></select>"
)
)
.
append
(
valueObj
(
"<select id='appendSelect1'></select>"
)
)
.
append
(
valueObj
(
"<select id='appendSelect2'><option>Test</option></select>"
)
);
.
append
(
valueObj
(
"<select id='appendSelect2'><option>Test</option></select>"
)
);
t
(
"Append Select"
,
"#appendSelect1, #appendSelect2"
,
[
"appendSelect1"
,
"appendSelect2"
]
);
t
(
"Append Select"
,
"#appendSelect1, #appendSelect2"
,
[
"appendSelect1"
,
"appendSelect2"
]
);
equal
(
"Two nodes"
,
jQuery
(
"<div />"
).
append
(
"Two"
,
" nodes"
).
text
(),
"Appending two text nodes (#4011)"
);
equal
(
"Two nodes"
,
jQuery
(
"<div />"
).
append
(
"Two"
,
" nodes"
).
text
(),
"Appending two text nodes (#4011)"
);
equal
(
jQuery
(
"<div />"
).
append
(
"1"
,
""
,
3
).
text
(),
"13"
,
"If median is false-like value, subsequent arguments should not be ignored"
);
// using contents will get comments regular, text, and comment nodes
// using contents will get comments regular, text, and comment nodes
j
=
jQuery
(
"#nonnodes"
).
contents
();
j
=
jQuery
(
"#nonnodes"
).
contents
();
...
...
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