diff --git a/src/manipulation.js b/src/manipulation.js index 602076a1b..220e09d46 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -456,6 +456,10 @@ function cloneFixAttributes( src, dest ) { // cloning other types of input fields } else if ( nodeName === "input" || nodeName === "textarea" ) { dest.defaultValue = src.defaultValue; + + // IE blanks contents when cloning scripts + } else if ( nodeName === "script" && dest.text !== src.text ) { + dest.text = src.text; } // Event data gets referenced instead of copied if the expando diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 49402b8a3..21d1f5f93 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1169,6 +1169,15 @@ test("clone()", function() { equal( jQuery("body").clone().children()[0].id, "qunit-header", "Make sure cloning body works" ); }); +test("clone(script type=non-javascript) (#11359)", function() { + expect(3); + var src = jQuery(""); + var dest = src.clone(); + equal( dest[0].text, "Lorem ipsum dolor sit amet", "Cloning preserves script text" ); + equal( dest.last().html(), src.last().html(), "Cloning preserves nested script text" ); + ok( /^\s*consectetur adipiscing elit<\/scr.pt>\s*$/i.test( dest.last().html() ), "Cloning preserves nested script text" ); +}); + test("clone(form element) (Bug #3879, #6655)", function() { expect(5); var element = jQuery("");