diff --git a/src/manipulation.js b/src/manipulation.js index 43bf377461..e7de7a6215 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -423,6 +423,14 @@ function cloneFixAttributes( src, dest ) { if ( nodeName === "object" ) { dest.outerHTML = src.outerHTML; + // 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 diff --git a/test/index.html b/test/index.html index c1320ccad0..fa52c0468b 100644 --- a/test/index.html +++ b/test/index.html @@ -135,6 +135,7 @@

+ diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 6776795911..cf1ecf862d 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -568,6 +568,15 @@ test("IE8 serialization bug", function () { 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 ); @@ -1771,4 +1780,4 @@ test("Guard against exceptions when clearing safeChildNodes", function() { } catch(e) {} ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" ); -}); \ No newline at end of file +});