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
3ad0ba62
Commit
3ad0ba62
authored
Oct 12, 2011
by
timmywil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not call getElements on a script tag. Avoids unnecessary execution. Fixes #10176.
parent
92b06d30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
manipulation.js
src/manipulation.js
+6
-4
manipulation.js
test/unit/manipulation.js
+8
-2
No files found.
src/manipulation.js
View file @
3ad0ba62
...
@@ -530,10 +530,10 @@ jQuery.each({
...
@@ -530,10 +530,10 @@ jQuery.each({
});
});
function
getAll
(
elem
)
{
function
getAll
(
elem
)
{
if
(
"getElementsByTagName"
in
elem
)
{
if
(
typeof
elem
.
getElementsByTagName
!==
"undefined"
)
{
return
elem
.
getElementsByTagName
(
"*"
);
return
elem
.
getElementsByTagName
(
"*"
);
}
else
if
(
"querySelectorAll"
in
elem
)
{
}
else
if
(
typeof
elem
.
querySelectorAll
!==
"undefined"
)
{
return
elem
.
querySelectorAll
(
"*"
);
return
elem
.
querySelectorAll
(
"*"
);
}
else
{
}
else
{
...
@@ -549,9 +549,11 @@ function fixDefaultChecked( elem ) {
...
@@ -549,9 +549,11 @@ function fixDefaultChecked( elem ) {
}
}
// Finds all inputs and passes them to fixDefaultChecked
// Finds all inputs and passes them to fixDefaultChecked
function
findInputs
(
elem
)
{
function
findInputs
(
elem
)
{
if
(
jQuery
.
nodeName
(
elem
,
"input"
)
)
{
var
nodeName
=
(
elem
.
nodeName
||
""
).
toLowerCase
();
if
(
nodeName
===
"input"
)
{
fixDefaultChecked
(
elem
);
fixDefaultChecked
(
elem
);
}
else
if
(
"getElementsByTagName"
in
elem
)
{
// Skip scripts, get other children
}
else
if
(
nodeName
!==
"script"
&&
typeof
elem
.
getElementsByTagName
!==
"undefined"
)
{
jQuery
.
grep
(
elem
.
getElementsByTagName
(
"input"
),
fixDefaultChecked
);
jQuery
.
grep
(
elem
.
getElementsByTagName
(
"input"
),
fixDefaultChecked
);
}
}
}
}
...
...
test/unit/manipulation.js
View file @
3ad0ba62
...
@@ -531,7 +531,7 @@ test("append(xml)", function() {
...
@@ -531,7 +531,7 @@ test("append(xml)", function() {
});
});
test
(
"appendTo(String|Element|Array<Element>|jQuery)"
,
function
()
{
test
(
"appendTo(String|Element|Array<Element>|jQuery)"
,
function
()
{
expect
(
1
6
);
expect
(
1
7
);
var
defaultText
=
"Try them out:"
var
defaultText
=
"Try them out:"
jQuery
(
"<b>buga</b>"
).
appendTo
(
"#first"
);
jQuery
(
"<b>buga</b>"
).
appendTo
(
"#first"
);
...
@@ -579,7 +579,7 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
...
@@ -579,7 +579,7 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
jQuery
(
"#moretests div:last"
).
click
();
jQuery
(
"#moretests div:last"
).
click
();
QUnit
.
reset
();
QUnit
.
reset
();
var
div
=
jQuery
(
"<div/>"
).
appendTo
(
"#qunit-fixture, #moretests"
);
div
=
jQuery
(
"<div/>"
).
appendTo
(
"#qunit-fixture, #moretests"
);
equals
(
div
.
length
,
2
,
"appendTo returns the inserted elements"
);
equals
(
div
.
length
,
2
,
"appendTo returns the inserted elements"
);
...
@@ -603,6 +603,12 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
...
@@ -603,6 +603,12 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
equals
(
jQuery
(
"#qunit-fixture div"
).
length
,
num
,
"Make sure all the removed divs were inserted."
);
equals
(
jQuery
(
"#qunit-fixture div"
).
length
,
num
,
"Make sure all the removed divs were inserted."
);
QUnit
.
reset
();
QUnit
.
reset
();
stop
();
jQuery
.
getScript
(
'data/test.js'
,
function
()
{
jQuery
(
'script[src*="data
\\
/test
\\
.js"]'
).
remove
();
start
();
});
});
});
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