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
0c2d1aee
Commit
0c2d1aee
authored
Apr 30, 2011
by
Rick Waldron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jQuery.buildFragment, ensure doc is a document; Includes comments; Adds unit test. Fixes #8950
parent
e2bace8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
manipulation.js
src/manipulation.js
+17
-4
manipulation.js
test/unit/manipulation.js
+10
-1
No files found.
src/manipulation.js
View file @
0c2d1aee
...
@@ -437,8 +437,21 @@ function cloneFixAttributes( src, dest ) {
...
@@ -437,8 +437,21 @@ function cloneFixAttributes( src, dest ) {
}
}
jQuery
.
buildFragment
=
function
(
args
,
nodes
,
scripts
)
{
jQuery
.
buildFragment
=
function
(
args
,
nodes
,
scripts
)
{
var
fragment
,
cacheable
,
cacheresults
,
var
fragment
,
cacheable
,
cacheresults
,
doc
;
doc
=
(
nodes
&&
nodes
[
0
]
?
nodes
[
0
].
ownerDocument
||
nodes
[
0
]
:
document
);
// nodes may contain either an explicit document object,
// a jQuery collection or context object.
// If nodes[0] contains a valid object to assign to doc
if
(
nodes
&&
nodes
[
0
]
)
{
doc
=
nodes
[
0
].
ownerDocument
||
nodes
[
0
];
}
// Ensure that an attr object doesn't incorrectly stand in as a document object
// Chrome and Firefox seem to allow this to occur and will throw exception
// Fixes #8950
if
(
!
doc
.
createDocumentFragment
)
{
doc
=
document
;
}
// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
// Cloning options loses the selected state, so don't cache them
// Cloning options loses the selected state, so don't cache them
...
@@ -500,7 +513,7 @@ jQuery.each({
...
@@ -500,7 +513,7 @@ jQuery.each({
function
getAll
(
elem
)
{
function
getAll
(
elem
)
{
if
(
"getElementsByTagName"
in
elem
)
{
if
(
"getElementsByTagName"
in
elem
)
{
return
elem
.
getElementsByTagName
(
"*"
);
return
elem
.
getElementsByTagName
(
"*"
);
}
else
if
(
"querySelectorAll"
in
elem
)
{
}
else
if
(
"querySelectorAll"
in
elem
)
{
return
elem
.
querySelectorAll
(
"*"
);
return
elem
.
querySelectorAll
(
"*"
);
...
@@ -746,4 +759,4 @@ function evalScript( i, elem ) {
...
@@ -746,4 +759,4 @@ function evalScript( i, elem ) {
}
}
}
}
})(
jQuery
);
})(
jQuery
);
\ No newline at end of file
test/unit/manipulation.js
View file @
0c2d1aee
...
@@ -1382,6 +1382,15 @@ test("jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
...
@@ -1382,6 +1382,15 @@ test("jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
}
}
catch
(
e
)
{}
catch
(
e
)
{}
}
}
equals
(
$f
.
text
(),
bad
.
join
(
""
),
"Cached strings that match Object properties"
);
equals
(
$f
.
text
(),
bad
.
join
(
""
),
"Cached strings that match Object properties"
);
$f
.
remove
();
$f
.
remove
();
});
});
test
(
"jQuery.buildFragment - plain objects are not a document #8950"
,
function
()
{
expect
(
1
);
try
{
jQuery
(
'<input type="hidden">'
,
{});
ok
(
true
,
"Does not allow attribute object to be treated like a doc object"
);
}
catch
(
e
)
{}
});
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