Refer to sibling Polymer element in Dart? -
for past few hours have been struggling refer sibling element within polymer project. imagine following setup:
/* main.html */ <link rel="import" href="siblinga.html"> <link rel="import" href="siblingb.html"> <polymer-element name="app-main"> <template> <app-siblinga></app-siblinga> <app-siblingb></app-siblingb> </template> <script type="application/dart" src="main.dart"></script> </polymer-element> /* siblinga.html, nothing special */ <polymer-element name="app-siblinga"> <template> <button on-click="{{dosomething))">do something</button> </template> <script type="application/dart" src="siblinga.dart"></script> </polymer-element> /* siblinga.dart */ import 'package:polymer/polymer.dart'; import 'dart:html'; @customtag('app-siblinga') class siblinga extends polymerelement { bool applyauthorstyles => true; siblinga.created() : super.created() { } void dosomething(mouseevent e, var detail, node target) { var profile = document.queryselector('app-siblingb'); print(profile); // null, why? } }
now can app-main
node document, fails on getting sibling elements. have tried getting sibling element via shadowroot
without success.
how can sibling element, in case app-siblingb
, document
or shadowroot
?
your siblings within shadowdom of <app-main>
. document.queryselector()
doesn't reach shadowdom of element.
this should work
(parentnode shadowroot).queryselector('app-siblingb');
Comments
Post a Comment