Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
correctly watch documents for script changes while parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Jan 25, 2014
1 parent a2accf9 commit 52e441c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ var importParser = {
// all parsable elements in inDocument (depth-first pre-order traversal)
var elts = doc.querySelectorAll(importParser.selectors);
// memoize the number of scripts
var scriptCount = document.scripts ? document.scripts.length : 0;
var scriptCount = doc.scripts ? doc.scripts.length : 0;
// for each parsable node type, call the mapped parsing method
for (var i=0, e; i<elts.length && (e=elts[i]); i++) {
importParser[importParser.map[e.localName]](e);
// if a script was injected, we need to requery our nodes
// TODO(sjmiles): injecting nodes above the current script will
// result in errors
if (document.scripts && scriptCount !== document.scripts.length) {
if (doc.scripts && scriptCount !== doc.scripts.length) {
// memoize the new count
scriptCount = document.scripts.length;
scriptCount = doc.scripts.length;
// ensure we have any new nodes in our list
elts = doc.querySelectorAll(importParser.selectors);
}
Expand Down

0 comments on commit 52e441c

Please sign in to comment.