File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -456,6 +456,10 @@ function cloneFixAttributes( src, dest ) {
456
456
// cloning other types of input fields
457
457
} else if ( nodeName === "input" || nodeName === "textarea" ) {
458
458
dest . defaultValue = src . defaultValue ;
459
+
460
+ // IE blanks contents when cloning scripts
461
+ } else if ( nodeName === "script" && dest . text !== src . text ) {
462
+ dest . text = src . text ;
459
463
}
460
464
461
465
// Event data gets referenced instead of copied if the expando
Original file line number Diff line number Diff line change @@ -1169,6 +1169,15 @@ test("clone()", function() {
1169
1169
equal ( jQuery ( "body" ) . clone ( ) . children ( ) [ 0 ] . id , "qunit-header" , "Make sure cloning body works" ) ;
1170
1170
} ) ;
1171
1171
1172
+ test ( "clone(script type=non-javascript) (#11359)" , function ( ) {
1173
+ expect ( 3 ) ;
1174
+ var src = jQuery ( "<script type='text/filler'>Lorem ipsum dolor sit amet</script><q><script type='text/filler'>consectetur adipiscing elit</script></q>" ) ;
1175
+ var dest = src . clone ( ) ;
1176
+ equal ( dest [ 0 ] . text , "Lorem ipsum dolor sit amet" , "Cloning preserves script text" ) ;
1177
+ equal ( dest . last ( ) . html ( ) , src . last ( ) . html ( ) , "Cloning preserves nested script text" ) ;
1178
+ ok ( / ^ \s * < s c r .p t \s + t y p e = [ ' " ] ? t e x t \/ f i l l e r [ ' " ] ? \s * > c o n s e c t e t u r a d i p i s c i n g e l i t < \/ s c r .p t > \s * $ / i. test ( dest . last ( ) . html ( ) ) , "Cloning preserves nested script text" ) ;
1179
+ } ) ;
1180
+
1172
1181
test ( "clone(form element) (Bug #3879, #6655)" , function ( ) {
1173
1182
expect ( 5 ) ;
1174
1183
var element = jQuery ( "<select><option>Foo</option><option selected>Bar</option></select>" ) ;
You can’t perform that action at this time.
0 commit comments