Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixes #1721: CDATA support in text/coffeescript <script> tags

  • Loading branch information...
commit be6e4ca6d1f5b64e0b126e31c3995184bcbfa527 1 parent d359764
Michael Ficarra michaelficarra authored
2  extras/coffee-script.js
1 addition, 1 deletion not shown
6 lib/coffee-script/browser.js
@@ -51,13 +51,15 @@
51 51 index = 0;
52 52 length = coffees.length;
53 53 (execute = function() {
54   - var script;
  54 + var match, script, src;
55 55 script = coffees[index++];
56 56 if ((script != null ? script.type : void 0) === 'text/coffeescript') {
57 57 if (script.src) {
58 58 return CoffeeScript.load(script.src, execute);
59 59 } else {
60   - CoffeeScript.run(script.innerHTML);
  60 + src = script.innerHTML;
  61 + if (match = src.match(/^\s*<!\[CDATA\[([\S\s]*)]]>\s*$/)) src = match[1];
  62 + CoffeeScript.run(src);
61 63 return execute();
62 64 }
63 65 }
5 src/browser.coffee
@@ -43,7 +43,10 @@ runScripts = ->
43 43 if script.src
44 44 CoffeeScript.load script.src, execute
45 45 else
46   - CoffeeScript.run script.innerHTML
  46 + src = script.innerHTML
  47 + if match = src.match /^\s*<!\[CDATA\[([\S\s]*)]]>\s*$/
  48 + src = match[1]
  49 + CoffeeScript.run src
47 50 execute()
48 51 null
49 52

0 comments on commit be6e4ca

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