Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

<script>s are not necessarily JavaScript.

We use jQuery templates, which expects <script
type="text/x-jquery-tmpl"> tags for the template contents. (There are
reasons to use <script> instead of e.g. <div>, but those aren't really
relevant; the point is that <script> is not necessarily JS.)

This patch checks the language processors to ensure the called type
exists before trying to call a non-existent method (the code was here to
support this, but the method call wasn't properly guarded.)

I also modified the browser tests to check for this.
  • Loading branch information...
commit 0456893d695a88e5c07c0d63ed2aa0ee37616b0f 1 parent bf31ec7
Sean Coates scoates authored assaf committed
Showing with 8 additions and 1 deletion.
  1. +6 −0 spec/browser-spec.coffee
  2. +2 −1  src/zombie/jsdom_patches.coffee
6 spec/browser-spec.coffee
View
@@ -22,6 +22,9 @@ brains.get "/scripted", (req, res)-> res.send """
document.title = "Nice";
$(function() { $("title").text("Awesome") })
</script>
+ <script type="text/x-do-not-parse">
+ <p>this is not valid JavaScript</p>
+ </script>
</html>
"""
@@ -250,6 +253,9 @@ vows.describe("Browser").addBatch(
document.title = "Nice";
$(function() { $("title").text("Awesome") })
</script>
+ <script type="text/x-do-not-parse">
+ <p>this is not valid JavaScript</p>
+ </script>
</html>
"""
3  src/zombie/jsdom_patches.coffee
View
@@ -78,7 +78,8 @@ core.Document.prototype._elementBuilders["script"] = (doc, s)->
filename = @ownerDocument.URL
@ownerDocument.parentWindow.perform (done)=>
loaded = (code, filename)=>
- core.languageProcessors[@language](this, code, filename) if code == @text
+ if core.languageProcessors[@language]?
+ core.languageProcessors[@language](this, code, filename) if code == @text
done()
core.resourceLoader.enqueue(this, loaded, filename)(null, code)
return script
Please sign in to comment.
Something went wrong with that request. Please try again.