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
13449a99
Commit
13449a99
authored
Dec 05, 2012
by
Paul Ramos
Committed by
Dave Methvin
Dec 05, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #11989. Remove fragment cache, moving to jquery-compat. Close gh-1052.
parent
ec72d9f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
101 deletions
+9
-101
core.js
src/core.js
+1
-2
manipulation.js
src/manipulation.js
+8
-35
manipulation.js
test/unit/manipulation.js
+0
-64
No files found.
src/core.js
View file @
13449a99
...
...
@@ -497,8 +497,7 @@ jQuery.extend({
if
(
scripts
)
{
jQuery
(
scripts
).
remove
();
}
return
jQuery
.
merge
(
[],
(
parsed
.
cacheable
?
jQuery
.
clone
(
parsed
.
fragment
)
:
parsed
.
fragment
).
childNodes
);
return
jQuery
.
merge
(
[],
parsed
.
childNodes
);
},
parseJSON
:
function
(
data
)
{
...
...
src/manipulation.js
View file @
13449a99
...
...
@@ -22,7 +22,6 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
rtbody
=
/<tbody/i
,
rhtml
=
/<|&#
?\w
+;/
,
rnoInnerhtml
=
/<
(?:
script|style|link
)
/i
,
rnocache
=
/<
(?:
script|style|object|embed|applet|option
)
/i
,
manipulation_rcheckableType
=
/^
(?:
checkbox|radio
)
$/i
,
// checked="checked" or checked
rchecked
=
/checked
\s
*
(?:[^
=
]
|=
\s
*.checked.
)
/i
,
...
...
@@ -315,7 +314,7 @@ jQuery.fn.extend({
if
(
this
[
0
]
)
{
results
=
jQuery
.
buildFragment
(
args
,
this
);
fragment
=
results
.
fragment
;
fragment
=
results
;
first
=
fragment
.
firstChild
;
if
(
fragment
.
childNodes
.
length
===
1
)
{
...
...
@@ -329,9 +328,9 @@ jQuery.fn.extend({
// Use the original fragment for the last item instead of the first because it can end up
// being emptied incorrectly in certain situations (#8070).
// Fragments from the fragment cache must always be cloned and never used in place.
for
(
iNoClone
=
results
.
cacheable
||
l
-
1
;
i
<
l
;
i
++
)
{
for
(
iNoClone
=
l
-
1
;
i
<
l
;
i
++
)
{
node
=
fragment
;
if
(
i
!==
iNoClone
)
{
node
=
jQuery
.
clone
(
node
,
true
,
true
);
...
...
@@ -340,6 +339,7 @@ jQuery.fn.extend({
jQuery
.
merge
(
scripts
,
getAll
(
node
,
"script"
)
);
}
}
callback
.
call
(
table
&&
jQuery
.
nodeName
(
this
[
i
],
"table"
)
?
findOrAppend
(
this
[
i
],
"tbody"
)
:
...
...
@@ -515,8 +515,7 @@ function cloneFixAttributes( src, dest ) {
}
jQuery
.
buildFragment
=
function
(
args
,
context
,
scripts
)
{
var
fragment
,
cacheable
,
cachehit
,
first
=
args
[
0
];
var
fragment
;
// Set context from what may come in as undefined or a jQuery collection or a node
// Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
...
...
@@ -525,38 +524,12 @@ jQuery.buildFragment = function( args, context, scripts ) {
context
=
!
context
.
nodeType
&&
context
[
0
]
||
context
;
context
=
context
.
ownerDocument
||
context
;
// 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
// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
// Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
if
(
args
.
length
===
1
&&
typeof
first
===
"string"
&&
first
.
length
<
512
&&
context
===
document
&&
first
.
charAt
(
0
)
===
"<"
&&
!
rnocache
.
test
(
first
)
&&
(
jQuery
.
support
.
checkClone
||
!
rchecked
.
test
(
first
))
&&
(
jQuery
.
support
.
html5Clone
||
!
rnoshimcache
.
test
(
first
))
)
{
// Mark cacheable and look for a hit
cacheable
=
true
;
fragment
=
jQuery
.
fragments
[
first
];
cachehit
=
fragment
!==
undefined
;
}
if
(
!
fragment
)
{
fragment
=
context
.
createDocumentFragment
();
jQuery
.
clean
(
args
,
context
,
fragment
,
scripts
);
fragment
=
context
.
createDocumentFragment
();
jQuery
.
clean
(
args
,
context
,
fragment
,
scripts
);
// Update the cache, but only store false
// unless this is a second parsing of the same content
if
(
cacheable
)
{
jQuery
.
fragments
[
first
]
=
cachehit
&&
fragment
;
}
}
return
{
fragment
:
fragment
,
cacheable
:
cacheable
};
return
fragment
;
};
jQuery
.
fragments
=
{};
jQuery
.
each
({
appendTo
:
"append"
,
prependTo
:
"prepend"
,
...
...
test/unit/manipulation.js
View file @
13449a99
...
...
@@ -689,21 +689,6 @@ if ( jQuery.css ) {
});
}
test
(
"html5 clone() cannot use the fragment cache in IE (#6485)"
,
function
()
{
expect
(
1
);
var
clone
;
jQuery
(
"<article><section><aside>HTML5 elements</aside></section></article>"
).
appendTo
(
"#qunit-fixture"
);
clone
=
jQuery
(
"article"
).
clone
();
jQuery
(
"#qunit-fixture"
).
append
(
clone
);
equal
(
jQuery
(
"aside"
).
length
,
2
,
"clone()ing HTML5 elems does not collapse them"
);
});
test
(
"html(String) with HTML5 (Bug #6485)"
,
function
()
{
expect
(
2
);
...
...
@@ -2112,55 +2097,6 @@ test( "Cloned, detached HTML5 elems (#10667,10670)", function() {
$clone
.
unbind
(
"click"
);
});
test
(
"jQuery.fragments cache expectations"
,
function
()
{
expect
(
10
);
jQuery
.
fragments
=
{};
function
fragmentCacheSize
()
{
var
c
,
n
=
0
;
for
(
c
in
jQuery
.
fragments
)
{
n
++
;
}
return
n
;
}
jQuery
(
"<li></li>"
);
jQuery
(
"<li>?</li>"
);
jQuery
(
"<li>whip</li>"
);
jQuery
(
"<li>it</li>"
);
jQuery
(
"<li>good</li>"
);
jQuery
(
"<div></div>"
);
jQuery
(
"<div><div><span></span></div></div>"
);
jQuery
(
"<tr><td></td></tr>"
);
jQuery
(
"<tr><td></tr>"
);
jQuery
(
"<li>aaa</li>"
);
jQuery
(
"<ul><li>?</li></ul>"
);
jQuery
(
"<div><p>arf</p>nnn</div>"
);
jQuery
(
"<div><p>dog</p>?</div>"
);
jQuery
(
"<span><span>"
);
equal
(
fragmentCacheSize
(),
12
,
"12 entries exist in jQuery.fragments, 1"
);
jQuery
.
each
(
[
"<tr><td></td></tr>"
,
"<ul><li>?</li></ul>"
,
"<div><p>dog</p>?</div>"
,
"<span><span>"
],
function
(
i
,
frag
)
{
jQuery
(
frag
);
equal
(
jQuery
.
fragments
[
frag
].
nodeType
,
11
,
"Second call with "
+
frag
+
" creates a cached DocumentFragment, has nodeType 11"
);
ok
(
jQuery
.
fragments
[
frag
].
childNodes
.
length
,
"Second call with "
+
frag
+
" creates a cached DocumentFragment, has childNodes with length"
);
});
equal
(
fragmentCacheSize
(),
12
,
"12 entries exist in jQuery.fragments, 2"
);
});
test
(
"Guard against exceptions when clearing safeChildNodes"
,
function
()
{
expect
(
1
);
...
...
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