angular.dart
angular.dart copied to clipboard
Need a reliable way to query a component's child elements when useShadowDom = false
In scenarios where useShadowDom
is set to false, there's no reliable way to know when a component's template has been loaded into the DOM, and therefore no reliable way to query for child elements. Please see this detailed SO question for more details:
http://stackoverflow.com/questions/27988813/querying-child-elements-of-a-component-when-useshadowdom-false
I think in this case you should either use document.querySelector()
or use the _root
you inject in the 2nd code snippet inside onShadowRoot
like _root.querySelector()
. If there isn't a `shadowRoot you can't use it as an anchor for querying. (I also commented on the answer to your SO question)
I did attempt to query the _root element injected via constructor in the onShadowRoot method (see the edit in my SO question). It seems to me that when constructing the EmulatedShadowRoot (shadowDom: false and implement ShadowRootAware) the web platform shim attempts to do some stuff that is failing, even when not querying the shadowRoot object.
Assigning to Victor to reply with a more comprehensive answer
@bgourlie see my answer http://stackoverflow.com/questions/27988813/querying-child-elements-of-a-component-when-useshadowdom-false