Skip to content
Browse files

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

  • Loading branch information...
1 parent d359764 commit be6e4ca6d1f5b64e0b126e31c3995184bcbfa527 @michaelficarra michaelficarra committed Oct 21, 2011
Showing with 9 additions and 4 deletions.
  1. +1 −1 extras/coffee-script.js
  2. +4 −2 lib/coffee-script/browser.js
  3. +4 −1 src/browser.coffee
View
2 extras/coffee-script.js
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.
View
6 lib/coffee-script/browser.js
@@ -51,13 +51,15 @@
index = 0;
length = coffees.length;
(execute = function() {
- var script;
+ var match, script, src;
script = coffees[index++];
if ((script != null ? script.type : void 0) === 'text/coffeescript') {
if (script.src) {
return CoffeeScript.load(script.src, execute);
} else {
- CoffeeScript.run(script.innerHTML);
+ src = script.innerHTML;
+ if (match = src.match(/^\s*<!\[CDATA\[([\S\s]*)]]>\s*$/)) src = match[1];
+ CoffeeScript.run(src);
return execute();
}
}
View
5 src/browser.coffee
@@ -43,7 +43,10 @@ runScripts = ->
if script.src
CoffeeScript.load script.src, execute
else
- CoffeeScript.run script.innerHTML
+ src = script.innerHTML
+ if match = src.match /^\s*<!\[CDATA\[([\S\s]*)]]>\s*$/
+ src = match[1]
+ CoffeeScript.run src
execute()
null

0 comments on commit be6e4ca

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