Created
March 1, 2011 18:51
-
-
Save jtwb/849639 to your computer and use it in GitHub Desktop.
document.write
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* DJSParserSemantics.mixins.withParserDocwrite | |
* | |
* Parse HTML chunk, peek at the DOM and amend | |
* the live DOM with new nodes. Parsing must pause | |
* as soon as </script.*?> appears, so we force this | |
* by breaking the markup into chunks. | |
*/ | |
var write = function(parser, out) { | |
var chunks = out.split(/<\/script[^>]*>/); | |
DJSUtil.forEach(chunks, function(chunk, index){ | |
if (index < (chunks.length - 1)) { | |
chunk += "</script>"; | |
} else if (chunk == "") { | |
return; | |
} | |
DJSUtil.log('Parsing document.write content: ' + chunk); | |
parser.parseChunk(chunk); | |
parser.peek(); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment