Skip to content

Commit

Permalink
Remove $.globalEval and simplify passing of data to/from scripts run …
Browse files Browse the repository at this point in the history
…in global context.
  • Loading branch information
ccd0 committed Jul 26, 2019
1 parent 48022bb commit 5f4ae32
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/platform/$.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -416,19 +416,19 @@ $.queueTask = do ->
taskQueue.push arguments
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) ->
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
# XXX dwb
fn()
try
fn.call(data)
data

$.bytesToString = (size) ->
unit = 0 # Bytes
Expand Down

0 comments on commit 5f4ae32

Please # to comment.