aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-11-14 01:28:16 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-12-02 17:09:01 +0300
commit6680c1b29ea79bf33ac6bd31578755c7c514ed3e (patch)
tree7adc79e38ca230e9ddf0090145aa55491d1ddb29
parente077ffb083743f4a4b990f586c9d25d787e7b417 (diff)
downloadjquery-6680c1b29ea79bf33ac6bd31578755c7c514ed3e.tar.gz
jquery-6680c1b29ea79bf33ac6bd31578755c7c514ed3e.zip
Core: do not expose second argument of the `jQuery.globalEval`
Closes jquery/api.jquery.com#831 Closes gh-2718
-rw-r--r--src/core.js14
-rw-r--r--src/core/DOMEval.js14
-rw-r--r--src/manipulation.js5
3 files changed, 23 insertions, 10 deletions
diff --git a/src/core.js b/src/core.js
index 9095213eb..3a54ffc0e 100644
--- a/src/core.js
+++ b/src/core.js
@@ -8,8 +8,10 @@ define( [
"./var/class2type",
"./var/toString",
"./var/hasOwn",
- "./var/support"
-], function( arr, document, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) {
+ "./var/support",
+ "./core/DOMEval"
+], function( arr, document, slice, concat,
+ push, indexOf, class2type, toString, hasOwn, support, DOMEval ) {
var
version = "@VERSION",
@@ -258,12 +260,8 @@ jQuery.extend( {
},
// Evaluates a script in a global context
- globalEval: function( code, context ) {
- context = context || document;
- var script = context.createElement( "script" );
-
- script.text = code;
- context.head.appendChild( script ).parentNode.removeChild( script );
+ globalEval: function( code ) {
+ DOMEval( code );
},
// Convert dashed to camelCase; used by the css and data modules
diff --git a/src/core/DOMEval.js b/src/core/DOMEval.js
new file mode 100644
index 000000000..222b0ca2a
--- /dev/null
+++ b/src/core/DOMEval.js
@@ -0,0 +1,14 @@
+define( [
+ "../var/document"
+], function( document ) {
+ function DOMEval( code, doc ) {
+ doc = doc || document;
+
+ var script = doc.createElement( "script" );
+
+ script.text = code;
+ doc.head.appendChild( script ).parentNode.removeChild( script );
+ }
+
+ return DOMEval;
+} );
diff --git a/src/manipulation.js b/src/manipulation.js
index eaf2e0998..cc4fd16cd 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -15,6 +15,7 @@ define( [
"./data/var/dataPriv",
"./data/var/dataUser",
"./data/var/acceptData",
+ "./core/DOMEval",
"./core/init",
"./traversing",
@@ -23,7 +24,7 @@ define( [
], function( jQuery, concat, push, access,
rcheckableType, rtagName, rscriptType,
wrapMap, getAll, setGlobalEval, buildFragment, support,
- dataPriv, dataUser, acceptData ) {
+ dataPriv, dataUser, acceptData, DOMEval ) {
var
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
@@ -192,7 +193,7 @@ function domManip( collection, args, callback, ignored ) {
jQuery._evalUrl( node.src );
}
} else {
- jQuery.globalEval( node.textContent.replace( rcleanScript, "" ), doc );
+ DOMEval( node.textContent.replace( rcleanScript, "" ), doc );
}
}
}