]> source.dussan.org Git - jquery.git/commitdiff
Fix #10324. IE9 fumbles the innerHTML on object elements.
authorRick Waldron <waldron.rick@gmail.com>
Wed, 11 Apr 2012 01:38:11 +0000 (21:38 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Wed, 11 Apr 2012 01:38:11 +0000 (21:38 -0400)
1  2 
src/manipulation.js
test/unit/manipulation.js

index 43bf37746194b0c2a891ee6e7eb99b0628f3a97f,9b9872a5cd0758f324fb49960b7d83e75220ade6..e7de7a6215eb4d8dfbb6f4ee976671d61b46664e
@@@ -423,7 -435,14 +423,15 @@@ function cloneFixAttributes( src, dest 
        if ( nodeName === "object" ) {
                dest.outerHTML = src.outerHTML;
  
 -      } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
+               // This path appears unavoidable for IE9. When cloning an object
+               // element in IE9, the outerHTML strategy above is not sufficient.
+               // If the src has innerHTML and the destination does not,
+               // copy the src.innerHTML into the dest.innerHTML. #10324
+               if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
+                       dest.innerHTML = src.innerHTML;
+               }
++
 +      } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
                // IE6-8 fails to persist the checked state of a cloned checkbox
                // or radio button. Worse, IE6-7 fail to give the cloned element
                // a checked appearance if the defaultChecked value isn't also set
index 6776795911ae612827bee9a5e27d52bd8ccf4111,b07423a3f503fbee8e11f41417d6492b82fec28a..cf1ecf862d88d60a287faf84b34e6c1aea2b03e5
@@@ -555,19 -551,15 +555,28 @@@ test("html(String) with HTML5 (Bug #648
        equal( jQuery("#qunit-fixture").children().children().children().length, 1, "Make sure nested HTML5 elements can hold children." );
  });
  
 +
 +
 +test("IE8 serialization bug", function () {
 +      expect(2);
 +      var wrapper = jQuery("<div></div>");
 +
 +      wrapper.html("<div></div><article></article>");
 +      equal( wrapper.children("article").length, 1, "HTML5 elements are insertable with .html()");
 +      
 +      wrapper.html("<div></div><link></link>");
 +      equal( wrapper.children("link").length, 1, "Link elements are insertable with .html()");
 +});
 +
+ test("html() object element #10324", function() {
+       expect( 1 );
+       var object = jQuery("#object2"),
+                       clone = object.clone();
+       equal( clone.html(), object.html(), "html() returns correct innerhtml of cloned object elements" );
+ });
  test("append(xml)", function() {
        expect( 1 );