-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update jsdom in htmlizer 0.x #21
Comments
Is it ok if I update to jsdom 9.2.1? |
1. jQuery.parseHTML on jsdom 3.1.2+ removes doctype, html, head and body tag. As a workaround, some handling for full HTML document template is done based on an assumption that the first tag of the document is an <html> tag (excluding doctype) when one wants to parse an entire document. 2. Detects doctype and prepend it to toString() output. .
Ok, now I remember why I didn't update jsdom. Htmlizer relies on jQuery.parseHTML for parsing HTML string to DOM nodes. As a workaround, now I detect if document begins with a <html> tag and then use a different parsing trick. The limitation are:
Tell me if you are ok with the above limitations. |
@mwoc, upgrading to htmlizer 2 should be far easier. It doesn't depend on jsdom at all (except as a dev dep), is faster and has the same API (iirc). |
@mwoc Yea, very few things have changed in htmlizer2. From the README file:
BTW, has anyone noticed that knockout itself can be run on node (by first declaring a global window and document object)? As far as I've tested it, even ko.observable and change updates also works. |
I'll take a look at upgrading to v2 then. I think I tried while I was upgrading to node v6, and something else broke when using htmlizer, probably hitting one of the API changes. Will let you know how it goes this time :) |
@mwoc Did you solve your issues with v2? |
I'm working now on updating to v2, and ran into issue #22 which I now remember earlier was the reason why I wanted to stick to v0.x for now. |
We're using htmlizer 0.8.0 in a project we wish to update to node v6, without updating to htmlizer v2 in the same iteration. This breaks due to jsdom's interface supposedly breaking when recompiling on nodejs v6:
___/htmlizer/node_modules/jsdom/lib/jsdom/level1/core.js:553
Array.prototype.splice.call(this._childNodes, refChildIndex, 0, newChild);
^
TypeError: Cannot set property length of [object Object] which has only a getter
at DocumentFragment.core.Node.insertBefore (/htmlizer/node_modules/jsdom/lib/jsdom/level1/core.js:553:30)
at DocumentFragment. (/htmlizer/node_modules/jsdom/lib/jsdom/level2/events.js:332:20)
at DocumentFragment.proto.(anonymous function) as insertBefore
at DocumentFragment.core.Node.appendChild (_/htmlizer/node_modules/jsdom/lib/jsdom/level1/core.js:671:17)
at ___/htmlizer/src/jquery.js:3:2360
at __/htmlizer/src/jquery.js:3:2615
at b.object.module.object.module.exports.module.exports (/htmlizer/src/jquery.js:2:201)
at window (_/htmlizer/src/Htmlizer.js:15:32)
at Object. (_/htmlizer/src/Htmlizer.js:24:2)
I tested with small increments to the jsdom version, and found that updating from 0.10.3 to 1.5.0 seems enough. For now, we've made a fork at https://github.com/mwoc/htmlizer/tree/v0 with this update, which probably is ok - but if others might need htmlizer v0.x to work on nodejs v6, then maybe an official patch might be worthwhile.
The text was updated successfully, but these errors were encountered: