From 22449eb968622c2e14d6c8d8de2cf1e1ba4adccd Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Fri, 6 Nov 2015 18:36:38 -0500 Subject: Manipulation: execute scripts from iframe in the iframe's context Fixes gh-1757 Close gh-2696 --- src/core.js | 7 ++++--- src/manipulation.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/core.js b/src/core.js index 8e43547ac..9095213eb 100644 --- a/src/core.js +++ b/src/core.js @@ -258,11 +258,12 @@ jQuery.extend( { }, // 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 diff --git a/src/manipulation.js b/src/manipulation.js index ceb970cbd..eaf2e0998 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -192,7 +192,7 @@ function domManip( collection, args, callback, ignored ) { jQuery._evalUrl( node.src ); } } else { - jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); + jQuery.globalEval( node.textContent.replace( rcleanScript, "" ), doc ); } } } -- cgit v1.2.3