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
bug: puppeteer: piercing on level 1 breaks #5717
Comments
I think this is working as expected based on the Stencil doc.
FWIW, I also thought this was a bug when the feature was introduced, as I would expect the opposite (explicit |
So I can not run the test in my reproducer repo without adding classes or something like that? What if I dont just have this simple component in component setup? Could be difficult to get the correct element if there are multiple levels with multiple ".label" classes in there. Maybe a solution could be to change the order of "look into all shadow roots": first of all check the level0 shadow, and if nothing found start searching in all other shadow roots. A little hint: the test in my reproducer repo breaks since 4.14.0, so this version is a breaking change release. Maybe mark it in some way. The docs could show an example, like:
... you need to use a helper class to select the lower |
I can see why this would be an interesting solution given how the current selector works. However all query commands usually work in a way that they find whatever element comes first in the DOM. Now, in a "Shadow-dom-less" world we could just do
Well, that behavior was broken (even if it was working for you). One workaround could be: await page.setContent('<my-component first="foo"></my-component2>');
const element = await page.find('my-component')
expect(element.shadowRoot.querySelector('.label').textContent)
.toEqualText("Hello, World! I'm foo"); |
Thanks for the workaround! But would be cool to have an E2EElement to do something like A last idea regarding "looking in all shadow doms" logic: |
@danyball can you please elaborate on this last idea? |
Sure: We have the sdx-teaser component. It has sdx-tag as a child in its shadow. Everything which has to do with sdx-tag is tested in tag.e2e. This component should be a "black box" for sdx-teaser. There is no need for a teaser test to go into the tag's shadow. I can not see a use case for that. And if I really want to, I could do it with >>>. |
I agree, this should be at least configurable, similar how the For now, all I can do is to ingest this into our backlog and find a resolution on this with the team. Thanks for your input. |
Prerequisites
Stencil Version
4.14.0
Current Behavior
We have a teaser component with this shadowRoot:
Our test wants to select the "foo" element. This works till 4.14.0:
const label = await page.find("sdx-teaser >>> .label")
Now the "bar" element in sdx-tag's shadowRoot gets selected, because it also has the .label class.
Expected Behavior
Not really sure if this is a bug or it works as designed by puppeteer. But my expectation is that a "level 1 piercing" should only select elements in its own shadowRoot.
System Info
Steps to Reproduce
Code Reproduction URL
https://github.com/danyball/stencil-piercing
Additional Information
No response
The text was updated successfully, but these errors were encountered: