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
46bbda8d
Commit
46bbda8d
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.
(cherry picked from commit
8e6c1ba9
)
parent
a777b355
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
+17
-11
manipulation.js
src/manipulation.js
+15
-10
manipulation.js
test/unit/manipulation.js
+2
-1
No files found.
src/manipulation.js
View file @
46bbda8d
...
...
@@ -619,8 +619,10 @@ jQuery.extend({
},
buildFragment
:
function
(
elems
,
context
,
scripts
,
selection
)
{
var
elem
,
i
,
j
,
tmp
,
tag
,
wrap
,
tbody
,
ret
=
[],
var
elem
,
j
,
tmp
,
tag
,
wrap
,
tbody
,
nodes
=
[],
i
=
0
,
l
=
elems
.
length
,
fragment
=
context
.
createDocumentFragment
(),
safe
=
context
===
document
&&
safeFragment
;
...
...
@@ -629,15 +631,16 @@ jQuery.extend({
context
=
document
;
}
for
(
i
=
0
;
(
elem
=
elems
[
i
])
!=
null
;
i
++
)
{
for
(
;
i
<
l
;
i
++
)
{
elem
=
elems
[
i
];
if
(
elem
||
elem
===
0
)
{
// Add nodes directly
if
(
jQuery
.
type
(
elem
)
===
"object"
)
{
jQuery
.
merge
(
ret
,
elem
.
nodeType
?
[
elem
]
:
elem
);
jQuery
.
merge
(
nodes
,
elem
.
nodeType
?
[
elem
]
:
elem
);
// Convert non-html into a text node
}
else
if
(
!
rhtml
.
test
(
elem
)
)
{
ret
.
push
(
context
.
createTextNode
(
elem
)
);
nodes
.
push
(
context
.
createTextNode
(
elem
)
);
// Convert html into DOM nodes
}
else
{
...
...
@@ -658,7 +661,7 @@ jQuery.extend({
// Manually add leading whitespace removed by IE
if
(
!
jQuery
.
support
.
leadingWhitespace
&&
rleadingWhitespace
.
test
(
elem
)
)
{
ret
.
push
(
context
.
createTextNode
(
rleadingWhitespace
.
exec
(
elem
)[
0
]
)
);
nodes
.
push
(
context
.
createTextNode
(
rleadingWhitespace
.
exec
(
elem
)[
0
]
)
);
}
// Remove IE's autoinserted <tbody> from table fragments
...
...
@@ -681,7 +684,7 @@ jQuery.extend({
}
}
jQuery
.
merge
(
ret
,
tmp
.
childNodes
);
jQuery
.
merge
(
nodes
,
tmp
.
childNodes
);
// Fix #12392 for WebKit and IE > 9
tmp
.
textContent
=
""
;
...
...
@@ -705,10 +708,11 @@ jQuery.extend({
// Reset defaultChecked for any radios and checkboxes
// about to be appended to the DOM in IE 6/7 (#8060)
if
(
!
jQuery
.
support
.
appendChecked
)
{
jQuery
.
grep
(
getAll
(
ret
,
"input"
),
fixDefaultChecked
);
jQuery
.
grep
(
getAll
(
nodes
,
"input"
),
fixDefaultChecked
);
}
for
(
i
=
0
;
(
elem
=
ret
[
i
])
!=
null
;
i
++
)
{
i
=
0
;
while
(
(
elem
=
nodes
[
i
++
])
)
{
safe
=
jQuery
.
contains
(
elem
.
ownerDocument
,
elem
);
// Append to fragment
...
...
@@ -726,7 +730,8 @@ jQuery.extend({
// Capture executables
if
(
scripts
)
{
for
(
j
=
0
;
(
elem
=
tmp
[
j
])
!=
null
;
j
++
)
{
j
=
0
;
while
(
(
elem
=
tmp
[
j
++
])
)
{
if
(
rscriptType
.
test
(
elem
.
type
||
""
)
)
{
scripts
.
push
(
elem
);
}
...
...
test/unit/manipulation.js
View file @
46bbda8d
...
...
@@ -395,7 +395,7 @@ var testAppendForObject = function( valueObj, isFragment ) {
var
testAppend
=
function
(
valueObj
)
{
expect
(
59
);
expect
(
60
);
testAppendForObject
(
valueObj
,
false
);
testAppendForObject
(
valueObj
,
true
);
...
...
@@ -464,6 +464,7 @@ var testAppend = function( valueObj ) {
t
(
"Append Select"
,
"#appendSelect1, #appendSelect2"
,
[
"appendSelect1"
,
"appendSelect2"
]
);
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
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