Skip to content

Commit 6680c1b

Browse files
committed
Core: do not expose second argument of the jQuery.globalEval
Closes jquery/api.jquery.com#831 Closes jquerygh-2718
1 parent e077ffb commit 6680c1b

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

src/core.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ define( [
88
"./var/class2type",
99
"./var/toString",
1010
"./var/hasOwn",
11-
"./var/support"
12-
], function( arr, document, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) {
11+
"./var/support",
12+
"./core/DOMEval"
13+
], function( arr, document, slice, concat,
14+
push, indexOf, class2type, toString, hasOwn, support, DOMEval ) {
1315

1416
var
1517
version = "@VERSION",
@@ -258,12 +260,8 @@ jQuery.extend( {
258260
},
259261

260262
// Evaluates a script in a global context
261-
globalEval: function( code, context ) {
262-
context = context || document;
263-
var script = context.createElement( "script" );
264-
265-
script.text = code;
266-
context.head.appendChild( script ).parentNode.removeChild( script );
263+
globalEval: function( code ) {
264+
DOMEval( code );
267265
},
268266

269267
// Convert dashed to camelCase; used by the css and data modules

src/core/DOMEval.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
define( [
2+
"../var/document"
3+
], function( document ) {
4+
function DOMEval( code, doc ) {
5+
doc = doc || document;
6+
7+
var script = doc.createElement( "script" );
8+
9+
script.text = code;
10+
doc.head.appendChild( script ).parentNode.removeChild( script );
11+
}
12+
13+
return DOMEval;
14+
} );

src/manipulation.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ define( [
1515
"./data/var/dataPriv",
1616
"./data/var/dataUser",
1717
"./data/var/acceptData",
18+
"./core/DOMEval",
1819

1920
"./core/init",
2021
"./traversing",
@@ -23,7 +24,7 @@ define( [
2324
], function( jQuery, concat, push, access,
2425
rcheckableType, rtagName, rscriptType,
2526
wrapMap, getAll, setGlobalEval, buildFragment, support,
26-
dataPriv, dataUser, acceptData ) {
27+
dataPriv, dataUser, acceptData, DOMEval ) {
2728

2829
var
2930
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
@@ -192,7 +193,7 @@ function domManip( collection, args, callback, ignored ) {
192193
jQuery._evalUrl( node.src );
193194
}
194195
} else {
195-
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ), doc );
196+
DOMEval( node.textContent.replace( rcleanScript, "" ), doc );
196197
}
197198
}
198199
}

0 commit comments

Comments
 (0)