diff --git a/CHANGELOG.md b/CHANGELOG.md index eb8d158a5..51ea47eb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ zombie.js-changelog(7) -- Changelog =================================== +## Version 1.1.6 2012-05-24 + +Tweak to in-line script processing to fix a problem no one reported. + + ## Version 1.1.5 2012-05-24 The `wait` function (and its derivatives) now return most recent error in diff --git a/lib/zombie/scripts.coffee b/lib/zombie/scripts.coffee index bc563d855..1d7b6e9ff 100644 --- a/lib/zombie/scripts.coffee +++ b/lib/zombie/scripts.coffee @@ -44,18 +44,17 @@ addInlineScriptSupport = (document)-> # listens on the script element itself, and someone the event it captures # doesn't have any of the script contents. document.addEventListener "DOMNodeInserted", (event)-> - # Get the script tag from the event itself - node = event.relatedNode + node = event.target # Node being inserted return unless node.tagName == "SCRIPT" - # Don't handle scripts with src URL, JSDOM takes care of these - return if node.src - code = node.text - return unless code - # Only process supported languages - language = HTML.languageProcessors[node.language] - return unless language - # Queue so inline scripts execute in order with external scripts - HTML.resourceLoader.enqueue(node, -> language(this, code, document.location.href))() + # Process scripts in order. + HTML.resourceLoader.enqueue(node, -> + code = node.text + # Only process supported languages + language = HTML.languageProcessors[node.language] + if code && language + # Queue so inline scripts execute in order with external scripts + language(this, code, document.location.href) + )() return diff --git a/test/script_test.coffee b/test/script_test.coffee index f5c151b56..5b20bf3fa 100644 --- a/test/script_test.coffee +++ b/test/script_test.coffee @@ -179,7 +179,8 @@ describe "Scripts", -> + document.title = document.title + "Two"; + """