How to access light DOM in Polymer.dart?

自闭症网瘾萝莉.ら 提交于 2019-12-07 13:51:20

问题


I'm looking for a way to access light DOM inside a custom Polymer.dart element.

my_element.html

<link rel="import" href="../../../../packages/polymer/polymer.html">
<polymer-element name="my-element">
  <template>
    <content></content>
  </template>
  <script type="application/dart" src="my_element.dart"></script>
</polymer-element>

my_element.dart

import 'package:polymer/polymer.dart';
import 'dart:html';

@CustomTag('my-element')
class MyElement extends PolymerElement {

  MyElement.created() : super.created() {}

  void attached() {
    // How to access the light DOM of this element?
  }
}

回答1:


To access light DOM simply call this.querySelector('<your-selector>')

To access the shadow DOM call shadowRoot.querySelector('<your-selector>')



来源:https://stackoverflow.com/questions/24935724/how-to-access-light-dom-in-polymer-dart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!