如何在Polymer.dart中访问light DOM?

时间:2014-07-24 13:55:04

标签: dart dart-polymer web-component

我正在寻找一种在自定义Polymer.dart元素中访问light DOM的方法。

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 个答案:

答案 0 :(得分:4)

要访问light DOM,只需致电this.querySelector('<your-selector>')

访问shadow DOM调用shadowRoot.querySelector('<your-selector>')