]> source.dussan.org Git - jquery.git/commitdiff
jQuery.clone() check that destination child nodes are not null. Fixes #9587 412/head
authorrwldrn <waldron.rick@gmail.com>
Wed, 15 Jun 2011 15:14:52 +0000 (11:14 -0400)
committerrwldrn <waldron.rick@gmail.com>
Wed, 15 Jun 2011 15:14:52 +0000 (11:14 -0400)
src/manipulation.js
test/index.html
test/unit/manipulation.js

index 439b9596bca760411c25470d5b05ff28bd6418f2..2f41feb9a8bfc8c6098ea41c2102f97754124ca6 100644 (file)
@@ -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 );
index 4b4c98552e7da5f5a469773415e4572fa2b97076..f3f235e093cbaf07cacec6cc84462511f9fc9da3 100644 (file)
@@ -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>
index b9bc75873cdffea5c3053a2394ea7fc6922021ad..4017cf196ed87f761bf301ea808f3906085e28fc 100644 (file)
@@ -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 );
+       }
+});