Timeline for this.template.querySelector works in parent template but not child template
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 13, 2021 at 22:21 | comment | added | glls | @RedQueries - shared a link for you in the post. feel free to update and share in your post | |
Sep 13, 2021 at 22:20 | history | edited | glls | CC BY-SA 4.0 |
deleted 291 characters in body
|
Sep 13, 2021 at 21:50 | comment | added | Phil W | It is true that if the element is not shown due to an if:true/false expression then it does not get rendered to the DOM and you will get undefined. | |
Sep 13, 2021 at 21:48 | comment | added | Phil W |
No. The template elements are not separate DOMs. Have you tried adding the "ul" element to the query selector, or even the .sidebar class, rather than having just the unadorned attribute selector?
|
|
Sep 13, 2021 at 21:44 | comment | added | glls | if the templates, are just nested templates within the same component, the DOM should be accessible iirc, as it is owned by the same component. If you have a template directive that prevents rendering of certain sections based on x conditions, that might be the actual issue. | |
Sep 13, 2021 at 21:26 | comment | added | RedQueries | Hi @phil w and glls, thank you for your help. One thing I may have mis-explained is that the markup is all in one component. There is no child component. What I meant was there are different layers of <template> within the component. By child I meant there are <template>'s within <template>. Does the same logic apply in terms of shadow DOM for nested <template>'s also as opposed to nested components? Maybe the same issue applies? Thanks again for your help. | |
Sep 13, 2021 at 18:42 | history | answered | glls | CC BY-SA 4.0 |