We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
var eventListener = function (evt) { if (!bodyContains(elt)) { eltToListenOn.removeEventListener(triggerSpec.trigger, eventListener); return; }
If I understand properly the code above, this checks if a node is part of body to avoid to run event listener if it is not the case anymore.
However, if elements from inside a shadow DOM are processed with code like
htmx.process(elt.shadowRoot)
bodyContains(elt) at the begin of eventListener always returns false because elt is part of shadow DOM.
bodyContains(elt)
false
elt
I propose the following fix to take care of shadow DOM nodes.
function bodyContains(elt) { if (elt.getRootNode() instanceof ShadowRoot) { return getDocument().body.contains(elt.getRootNode().host); } else { return getDocument().body.contains(elt); } }
Opinions ?
The text was updated successfully, but these errors were encountered:
Thank you for the change. Can you write a test that exercises this functionality?
Sorry, something went wrong.
@cg Tests are why I started the CI PR. I'll do my best to add one.
No branches or pull requests
If I understand properly the code above, this checks if a node is part of body to avoid to run event listener if it is not the case anymore.
However, if elements from inside a shadow DOM are processed with code like
bodyContains(elt)
at the begin of eventListener always returnsfalse
becauseelt
is part of shadow DOM.I propose the following fix to take care of shadow DOM nodes.
Opinions ?
The text was updated successfully, but these errors were encountered: