Skip to content

Commit

Permalink
Merge pull request turbolinks#88 from reednj77/handle-external-body-s…
Browse files Browse the repository at this point in the history
…cripts

Execute external script tags
  • Loading branch information
dhh committed Nov 26, 2012
2 parents 4be5e6d + 58cba6f commit 9ecff71
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/assets/javascripts/turbolinks.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@ changePage = (title, body, runScripts) ->
triggerEvent 'page:change'

executeScriptTags = ->
eval(script.innerHTML) for script in document.body.getElementsByTagName 'script' when script.type in ['', 'text/javascript']
for script in document.body.getElementsByTagName 'script' when script.type in ['', 'text/javascript']
if script.src? and not script.getAttribute('data-turbolinks-evaluated')?
copy = document.createElement 'script'
copy.setAttribute attr.name, attr.value for attr in script.attributes
copy.setAttribute 'data-turbolinks-evaluated', ''
parent = script.parentNode
parent.removeChild script
parent.insertBefore copy, parent.childNodes[0]
else
eval(script.innerHTML)


reflectNewUrl = (url) ->
Expand Down

0 comments on commit 9ecff71

Please sign in to comment.