-
-
Notifications
You must be signed in to c 8000 hange notification settings - Fork 1.7k
[bug] Cannot add property _currentElement, object is not extensible #3175
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
Comments
Yeah, jsdom is not compatible with other things which monkeypatch parse5, I guess. It's a shame we have to do so, but until inikulin/parse5#237 is fixed I don't see a way around that. |
Could we perhaps be at least a bit more careful with the monkey patching? I.e., do something like OpenElementStack.prototype.push = function (...args) {
openElementStackOriginalPush.apply(this, args);
+ if (this.treeAdapter instanceof JSDOMParse5Adapter) {
this.treeAdapter._currentElement = this.current;
+ }
const after = this.items[this.stackTop];
if (after._pushedOnStackOfOpenElements) {
after._pushedOnStackOfOpenElements();
}
}; That'll fix this case at least. |
This is almost certainly fixed by #3354. I won't add a regression test since pulling in third-party dependencies just for testing is a bit annoying. |
Basic info:
Minimal reproduction case
I pushed a minimal reproduction to this repo - https://github.com/boopathi/jsdom-bug-1
The CI build in that repo would provide the error details - https://github.com/boopathi/jsdom-bug-1/runs/2328255180?check_suite_focus=true
When JSDOM and parse5 (purgecss-from-html uses parse5) are used imported in the same context, the following error is thrown -
The stack trace of this error points to
jsdom/lib/jsdom/browser/parser/html.js
Lines 21 to 34 in e4c4004
How does similar code behave in browsers?
This section is not relevant for this issue.
(Link to a jsbin or similar strongly suggested.)
The text was updated successfully, but these errors were encountered: