-
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): shadow root childNodes #374
Conversation
childNodes: { value : [] }, | ||
childNodes: { | ||
get(this: ShadowRoot): Element[] { | ||
if (process.env.NODE_ENV !== 'production') { |
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 warning is tricky because it only appears when in fallback mode. On the other hands, blacklist will always throw. Maybe we need a grayList that wraps the original functionality with a warning, but still allow you to use it.
if (process.env.NODE_ENV !== 'production') { | ||
assert.logWarning(`childNodes on ${this} returns a live nodelist which is not stable. Use querySelectorAll instead.`); | ||
} | ||
return EmptyArray; |
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 supposed to return empty array only when the element tagName is a slot, otherwise it should return the proper values but as a static list, not a live one. I think that's better for selenium/webdriver, while keeping users out of trouble.
Benchmark resultsBase commit: lwc-engine-benchmark
|
Benchmark resultsBase commit: lwc-engine-benchmark
|
Benchmark resultsBase commit: lwc-engine-benchmark
|
Benchmark resultsBase commit: lwc-engine-benchmark
|
if (process.env.NODE_ENV !== 'production') { | ||
assert.logWarning(`childNodes on ${this} returns a live nodelist which is not stable. Use querySelectorAll instead.`); | ||
} | ||
const vm = getElementOwnerVM(this) as VM; |
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.
rename to ownerVM
Benchmark resultsBase commit: lwc-engine-benchmark
|
const elm = createElement('x-child-node-parent', { is: Parent }); | ||
document.body.appendChild(elm); | ||
const slot = elm.shadowRoot.querySelector('x-child-node-with-slot').shadowRoot.querySelector('slot'); | ||
expect(slot.childNodes.length).toBe(0); |
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.
expect(slot.childNodes).toHaveLength(0);
will give a better failure message.
Same comment for cases below.
browser.waitUntil(() => { | ||
return element.getText() === 'Title:task 1 Completed:false'; | ||
}, 500, 'expect text to be different after 0.5s'); | ||
browser.pause(50); |
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 we use the browser.execute
call inside the waitUntil
instead of this pause?
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! I didn't realize you could do that.
browser.waitUntil(() => { | ||
return element.getText() === 'Title:task 1 Completed:false'; | ||
}, 500, 'expect text to be different after 0.5s'); | ||
browser.pause(50); |
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.
Same comment as above - can we add browser.execute
to the wait?
Benchmark resultsBase commit: lwc-engine-benchmark
|
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 a coming PR right after.
Details
Adding
childNodes
shim to shadow root and templated elements.Does this PR introduce a breaking change?