-
Notifications
You must be signed in to change notification settings - Fork 392
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
Allow running in node environment #64
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change 👍 Impressive!
This is awesome. Thanks! 👏👏👏 |
🎉 This PR is included in version 2.0.4 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
!(htmlElement instanceof SVGElement) | ||
!htmlElement.ownerDocument && | ||
!(htmlElement instanceof htmlElement.ownerDocument.HTMLElement) && | ||
!(htmlElement instanceof htmlElement.ownerDocument.SVGElement) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this condition be this instead?
if (
!htmlElement.ownerDocument ||
(
!(htmlElement instanceof htmlElement.ownerDocument.HTMLElement) &&
!(htmlElement instanceof htmlElement.ownerDocument.SVGElement)
)
) {
throw new HtmlElementTypeError(htmlElement, matcherFn, context, validTypes)
}
If there's no htmlElement.ownerDocument
, it makes no sense to go and evaluate the rest of the condition, because the rest of the conditional depends entirely on htmlElement.ownerDocument
not being undefined.
Please, let me know if I'm correct or not so far. If I am, I have more things to say, but I wanted to confirm up to this point at least
cc @sheerun
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, here it is the additional part of what I wanted to say.
I think the above is never surfaced because checkHtmlElement
is coincidentally always called with a valid html element that has an ownerDocument
.
So we never really get to the point where the instanceof
parts of the conditions are evaluated even. The thing is, when I fixed the condition locally, I get that htmlElement.ownerDocument.HTMLElement
is undefined. The same with SVGElement
.
This is the point where I'm no longer sure how to continue this fix. Care to chime in @sheerun?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More insight into this. Code coverage is not at 100% for this src/utils.js
file. However, I'm not sure how that's not being captured by the travis build, which has always flagged code coverage less than 100%.
😕
@sheerun any comments on my concerns above? |
Fixes #58