-
Notifications
You must be signed in to change notification settings - Fork 400
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(engine): Fix composed: false getRootNode #170
Conversation
if (!composed && !isUndefined(node[ViewModelReflection])) { | ||
return node; // this is not quite the root (it is the host), but for us is sufficient | ||
if (!composed) { | ||
return findShadowRoot(node.parentNode); // this is not quite the root (it is the host), but for us is sufficient |
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 this is correct, but honestly am not 100% sure
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 don't understand how is this code different. I was avoiding the usage of recursive methods, instead use the while
statement to do the exact same that the new recursive method is doing. Or at least that was the intent. Let's chat more about this tomorrow morning.
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.
while loop over recursion
Benchmark comparisonBase commit:
|
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.
looks good to me, but we should have @caridy bless this
|
||
describe('dom', () => { | ||
describe('getRootNode composed true', () => { | ||
it('should return correct value from child node', () => { | ||
class MyComponent extends Element { |
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 is never used in this test.
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.
Fixed
|
||
const elm = createElement('x-parent', { is: Parent }); | ||
document.body.appendChild(elm); | ||
const child = elm.querySelector('div'); |
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.
don't do this here because it will be broken once we introduce shadow dom.
const elm = createElement('x-parent', { is: Parent }); | ||
document.body.appendChild(elm); | ||
const child = elm.querySelector('div'); | ||
const match = getRootNode.call(child, { composed: true }); |
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.
don't test getRootNode directly because it eventually will be replaced with the one from the browser.
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 whole point of the test is ensuring that our getRootNode
behaves correctly.
}); | ||
|
||
it('should return correct value from self', () => { | ||
class MyComponent extends Element { |
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.
not used.
Benchmark comparisonBase commit:
|
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.
small optimizations can be added
Benchmark comparisonBase commit:
|
* WIP: Fixing attrs to props in compiler (#167) * fix(compiler): Attributes on native DOM Elements * fix(compiler): Moving boolean attributes to props * fix(engine): Fix composed: false getRootNode (#170) * fix(engine): Fixing composed false in getRootNode * fix(engine): Removed recursion. Cleaned tests * fix(engine): lint * fix(engine): Small optimization * fix(engine): lint * chore(engine): Some more tests * fix(compiler): Fixing failing tests * chore(test): Adding assertion to integration test
Details
Passing
composed: false
togetRootNode
returned the same node passed in. This is incorrect and resulted in infinite loops in piercing.For reference, here is the expected behavior from Chrome (Web Component, not lightning web components):
Does this PR introduce a breaking change?