Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

<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
6 spec/browser-spec.coffee
@@ -22,6 +22,9 @@ brains.get "/scripted", (req, res)-> res.send """
22 22 document.title = "Nice";
23 23 $(function() { $("title").text("Awesome") })
24 24 </script>
  25 + <script type="text/x-do-not-parse">
  26 + <p>this is not valid JavaScript</p>
  27 + </script>
25 28 </html>
26 29 """
27 30
@@ -250,6 +253,9 @@ vows.describe("Browser").addBatch(
250 253 document.title = "Nice";
251 254 $(function() { $("title").text("Awesome") })
252 255 </script>
  256 + <script type="text/x-do-not-parse">
  257 + <p>this is not valid JavaScript</p>
  258 + </script>
253 259 </html>
254 260 """
255 261
3  src/zombie/jsdom_patches.coffee
@@ -78,7 +78,8 @@ core.Document.prototype._elementBuilders["script"] = (doc, s)->
78 78 filename = @ownerDocument.URL
79 79 @ownerDocument.parentWindow.perform (done)=>
80 80 loaded = (code, filename)=>
81   - core.languageProcessors[@language](this, code, filename) if code == @text
  81 + if core.languageProcessors[@language]?
  82 + core.languageProcessors[@language](this, code, filename) if code == @text
82 83 done()
83 84 core.resourceLoader.enqueue(this, loaded, filename)(null, code)
84 85 return script

0 comments on commit 0456893

Please sign in to comment.
Something went wrong with that request. Please try again.