},
// Evaluates a script in a global context
- globalEval: function( code ) {
- var script = document.createElement( "script" );
+ globalEval: function( code, context ) {
+ context = context || document;
+ var script = context.createElement( "script" );
script.text = code;
- document.head.appendChild( script ).parentNode.removeChild( script );
+ context.head.appendChild( script ).parentNode.removeChild( script );
},
// Convert dashed to camelCase; used by the css and data modules
jQuery._evalUrl( node.src );
}
} else {
- jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
+ jQuery.globalEval( node.textContent.replace( rcleanScript, "" ), doc );
}
}
}
--- /dev/null
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset=utf-8 />
+ <title>body</title>
+ </head>
+ <body>
+ <div id="qunit-fixture"></div>
+ <script src="../../jquery.js"></script>
+ <script>
+ window.parent.iframeCallback(
+ window,
+ document.body,
+ "<script>window.scriptTest = true;<\x2fscript>"
+ );
+ </script>
+ </body>
+</html>
}
);
+testIframeWithCallback(
+ "domManip executes scripts in iframes in the iframes' context",
+ "manipulation/scripts-context.html",
+ function( frameWindow, bodyElement, html, assert ) {
+ assert.expect( 2 );
+ jQuery( bodyElement ).append( html );
+ assert.ok( !window.scriptTest, "script executed in iframe context" );
+ assert.ok( frameWindow.scriptTest, "script executed in iframe context" );
+ }
+);
+
QUnit.test( "jQuery.clone - no exceptions for object elements #9587", function( assert ) {
assert.expect( 1 );