aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortimmywil <timmywillisn@gmail.com>2011-10-12 00:06:30 -0400
committertimmywil <timmywillisn@gmail.com>2011-10-12 00:06:54 -0400
commit3ad0ba62f03ff3d7aec7d3dfb25492cdf33350a7 (patch)
tree125a6db3dc3c84b844995a59d50911c358fbf723
parent92b06d302cc8e94d52e0c60c9167ec17606984f3 (diff)
downloadjquery-3ad0ba62f03ff3d7aec7d3dfb25492cdf33350a7.tar.gz
jquery-3ad0ba62f03ff3d7aec7d3dfb25492cdf33350a7.zip
Do not call getElements on a script tag. Avoids unnecessary execution. Fixes #10176.
-rw-r--r--src/manipulation.js10
-rw-r--r--test/unit/manipulation.js10
2 files changed, 14 insertions, 6 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index 0f7f9dd9b..11dca3100 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -530,10 +530,10 @@ jQuery.each({
});
function getAll( elem ) {
- if ( "getElementsByTagName" in elem ) {
+ if ( typeof elem.getElementsByTagName !== "undefined" ) {
return elem.getElementsByTagName( "*" );
- } else if ( "querySelectorAll" in elem ) {
+ } else if ( typeof elem.querySelectorAll !== "undefined" ) {
return elem.querySelectorAll( "*" );
} else {
@@ -549,9 +549,11 @@ function fixDefaultChecked( elem ) {
}
// Finds all inputs and passes them to fixDefaultChecked
function findInputs( elem ) {
- if ( jQuery.nodeName( elem, "input" ) ) {
+ var nodeName = (elem.nodeName || "").toLowerCase();
+ if ( nodeName === "input" ) {
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 );
}
}
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index c60c3201d..0b1a1e66a 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -531,7 +531,7 @@ test("append(xml)", function() {
});
test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
- expect(16);
+ expect(17);
var defaultText = "Try them out:"
jQuery("<b>buga</b>").appendTo("#first");
@@ -579,7 +579,7 @@ test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
jQuery("#moretests div:last").click();
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" );
@@ -603,6 +603,12 @@ test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
equals( jQuery("#qunit-fixture div").length, num, "Make sure all the removed divs were inserted." );
QUnit.reset();
+
+ stop();
+ jQuery.getScript('data/test.js', function() {
+ jQuery('script[src*="data\\/test\\.js"]').remove();
+ start();
+ });
});
var testPrepend = function(val) {