hexonaut/haxe-dom

NodeJs: Workaround for ArrayAccess problem affecting HtmlSerializer

Opened this issue · 0 comments

There seems to be a problem in how Haxe treats ArrayAccess in Node. This leads to that line 124 in HtmlSerializer.hx doesn't work - the variable a isn't set to the expected array item, instead it's null. ('unfinished' at runtime.)
Here's a workaround: instead of accessing the with square brackets (attributes[i]), they are accessed with the attributes.item(i) method already present in the dom4.Attr class.
With this quick fix, hxdom seems to work as expected for me in nodejs. (This far :-)
/ Jonas

// hxdom.HtmlSerializer, line 118
        //Add in attributes
        var attributes:NamedNodeMap = e.node.attributes;
        for (i in 0 ... attributes.length) {
            #if (js && !use_vdom)
            var a:Dynamic = attributes[i];
            #else
            var a:dom4.Attr = cast attributes.item(i); // <--- Here's the fix!
            #end
            buf.add(" " + a.name + "='" + a.value.htmlEscape(true) + "'");
        }