-
Notifications
You must be signed in to change notification settings - Fork 168
Open
Labels
Description
On node 0.6.3 and html5 v0.3.5, parsing multiple page fragments with the same parser sometimes causes failures in the treebuilder, which are caused by a pointer-unequal marker element in reconstructActiveFormattingElements and elementInActiveFormattingElements. The problem is mainly triggered if the parsed fragments contain tables.
The following patch converts the pointer equality based check into a node type check, which fixes the problem for me:
--- treebuilder.js 2011-11-28 21:30:17.675749830 +0100
+++ /usr/lib/node_modules/html5/lib/html5/treebuilder.js 2011-11-28 20:21:38.067593170 +0100
@@ -224,9 +224,9 @@
// Step 2 and 3: start with the last element
var i = this.activeFormattingElements.length - 1;
var entry = this.activeFormattingElements[i];
- if(entry == HTML5.Marker || this.open_elements.indexOf(entry) != -1) return;
+ if(entry.type == HTML5.Marker.type || this.open_elements.indexOf(entry) != -1) return;
- while(entry != HTML5.Marker && this.open_elements.indexOf(entry) == -1) {
+ while(entry.type != HTML5.Marker.type && this.open_elements.indexOf(entry) == -1) {
i -= 1;
entry = this.activeFormattingElements[i];
if(!entry) break;
@@ -248,7 +248,7 @@
b.prototype.elementInActiveFormattingElements = function(name) {
var els = this.activeFormattingElements;
for(var i = els.length - 1; i >= 0; i--) {
- if(els[i] == HTML5.Marker) break;
+ if(els[i].type == HTML5.Marker.type) break;
if(els[i].tagName.toLowerCase() == name) return els[i];
}
return false;