-
Notifications
You must be signed in to change notification settings - Fork 402
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
fix: getRootNode when composed is false and the element is the root #337
Conversation
* TODO: Once we start using the real shadowDOM, this method should be replaced by: | ||
* const { getRootNode } = Node.prototype; | ||
*/ | ||
function getRootNode( |
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.
this seems functional equivalent, just cosmetic changes. Can you confirm?
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 think that's correct
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.
Yes, you are right.
* It doesn't returns actually the root but the host. This approximation is sufficiant | ||
* in our case. | ||
*/ | ||
function findComposedRootNode(node: Node): Node { |
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.
can you explain what the problem was? in which scenario?
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.
The problem was finding the root node on an element rendered in interop. Since there is no parent VM, it was traversing to the document root. Because this isn't inside of a closed root, going to the document root seems correct.
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.
There is already a test case for this. https://github.com/salesforce/lwc/pull/337/files#diff-2a67454c78a85e47d3e8214bb464d731R114
However, if you look at the diff, the composed
was set to true instead of false, explaining why we didn't catch that before. I fixed the test.
Benchmark resultsBase commit: lwc-engine-benchmark
|
Details
Fix error throw in getRootNode when the component is the root of the component tree.
Does this PR introduce a breaking change?