Remove $.globalEval and simplify passing of data to/from scripts run in global context.
This commit is contained in:
parent
48022bb31b
commit
5f4ae3231f
@ -416,19 +416,19 @@ $.queueTask = do ->
|
|||||||
taskQueue.push arguments
|
taskQueue.push arguments
|
||||||
setTimeout execTask, 0
|
setTimeout execTask, 0
|
||||||
|
|
||||||
$.globalEval = (code, data) ->
|
|
||||||
script = $.el 'script',
|
|
||||||
textContent: code
|
|
||||||
$.extend script.dataset, data if data
|
|
||||||
$.add (d.head or doc), script
|
|
||||||
$.rm script
|
|
||||||
|
|
||||||
$.global = (fn, data) ->
|
$.global = (fn, data) ->
|
||||||
if doc
|
if doc
|
||||||
$.globalEval "(#{fn})();", data
|
script = $.el 'script',
|
||||||
|
textContent: "(#{fn}).call(document.currentScript.dataset);"
|
||||||
|
$.extend script.dataset, data if data
|
||||||
|
$.add (d.head or doc), script
|
||||||
|
$.rm script
|
||||||
|
script.dataset
|
||||||
else
|
else
|
||||||
# XXX dwb
|
# XXX dwb
|
||||||
fn()
|
try
|
||||||
|
fn.call(data)
|
||||||
|
data
|
||||||
|
|
||||||
$.bytesToString = (size) ->
|
$.bytesToString = (size) ->
|
||||||
unit = 0 # Bytes
|
unit = 0 # Bytes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user