aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwldrn <waldron.rick@gmail.com>2011-06-15 11:14:52 -0400
committerrwldrn <waldron.rick@gmail.com>2011-06-15 11:14:52 -0400
commit5c3b9e0c24dbb31245e9266dcd20fface92747eb (patch)
treee30cee1796f71003d84cb64f93f1027a34a95ad0
parentd59b0f3e27827d189b8b2595142ec6bbc3941dd9 (diff)
downloadjquery-5c3b9e0c24dbb31245e9266dcd20fface92747eb.tar.gz
jquery-5c3b9e0c24dbb31245e9266dcd20fface92747eb.zip
jQuery.clone() check that destination child nodes are not null. Fixes #9587
-rw-r--r--src/manipulation.js7
-rw-r--r--test/index.html2
-rw-r--r--test/unit/manipulation.js11
3 files changed, 18 insertions, 2 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index 439b9596b..2f41feb9a 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -564,7 +564,10 @@ jQuery.extend({
// with an element if you are cloning the body and one of the
// elements on the page has a name or id of "length"
for ( i = 0; srcElements[i]; ++i ) {
- cloneFixAttributes( srcElements[i], destElements[i] );
+ // Ensure that the destination node is not null; Fixes #9587
+ if ( destElements[i] ) {
+ cloneFixAttributes( srcElements[i], destElements[i] );
+ }
}
}
@@ -762,4 +765,4 @@ function evalScript( i, elem ) {
}
}
-})( jQuery ); \ No newline at end of file
+})( jQuery );
diff --git a/test/index.html b/test/index.html
index 4b4c98552..f3f235e09 100644
--- a/test/index.html
+++ b/test/index.html
@@ -281,6 +281,8 @@ Z</textarea>
</div>
<div id="fx-tests"></div>
+
+ <div id="no-clone-exception"><object><embed></embed></object></div>
</div>
</body>
</html>
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index b9bc75873..4017cf196 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -1465,3 +1465,14 @@ test("jQuery.buildFragment - plain objects are not a document #8950", function()
} catch (e) {}
});
+
+test("jQuery.clone - no exceptions for object elements #9587", function() {
+ expect(1);
+
+ try {
+ jQuery("#no-clone-exception").clone();
+ ok( true, "cloned with no exceptions" );
+ } catch( e ) {
+ ok( false, e.message );
+ }
+});