Skip to content

Commit

Permalink
Fix executeScriptTags for JS on HTML
Browse files Browse the repository at this point in the history
No src attribute script.src returns '', so avoid it.
Use eval() in the global scope.
  • Loading branch information
itzki committed Nov 27, 2012
1 parent be69c27 commit b3538bf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/assets/javascripts/turbolinks.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ changePage = (title, body, runScripts) ->

executeScriptTags = ->
for script in document.body.getElementsByTagName 'script' when script.type in ['', 'text/javascript']
if script.src? and not script.getAttribute('data-turbolinks-evaluated')?
if script.src? and script.src isnt '' 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)
window.eval(script.innerHTML)


reflectNewUrl = (url) ->
Expand Down

0 comments on commit b3538bf

Please sign in to comment.