Chromium Code Reviews| Index: pkg/polymer/lib/src/instance.dart |
| diff --git a/pkg/polymer/lib/src/instance.dart b/pkg/polymer/lib/src/instance.dart |
| index de911de6bad5e5b661140a5057c3ef59f5b8c815..bf55811e8c43e58752de6480b4df3862c1a34a10 100644 |
| --- a/pkg/polymer/lib/src/instance.dart |
| +++ b/pkg/polymer/lib/src/instance.dart |
| @@ -183,9 +183,8 @@ abstract class Polymer implements Element { |
| void parseDeclaration(Element elementElement) { |
| var root = shadowFromTemplate(fetchTemplate(elementElement)); |
| - // Dart note: this is extra code compared to Polymer to support |
| - // the getShadowRoot method. |
| - if (root == null) return; |
| + // Dart note: the following code is to support the getShadowRoot method. |
| + if (root is! ShadowRoot) return; |
| var name = elementElement.attributes['name']; |
| if (name == null) return; |
| @@ -198,7 +197,19 @@ abstract class Polymer implements Element { |
| Element fetchTemplate(Element elementElement) => |
| elementElement.query('template'); |
| - /** Utility function that creates a shadow root from a `<template>`. */ |
| + /** |
| + * Utility function that creates a shadow root from a `<template>`. |
| + * |
| + * The base implementation will return a [ShadowRoot], but you can replace it |
| + * with your own code and skip ShadowRoot creation. In that case, you should |
| + * return `null`. |
| + * |
| + * In your overridden method, you can use [instanceTemplate] to stamp the |
| + * template and initialize data binding, and [shadowRootReady] to intialize |
| + * other Polymer features like event handlers. It is fine to call |
| + * shadowRootReady with a node something other than a ShadowRoot; for example, |
| + * with this Node. |
| + */ |
| ShadowRoot shadowFromTemplate(Element template) { |
| if (template == null) return null; |
| // cache elder shadow root (if any) |
| @@ -226,7 +237,7 @@ abstract class Polymer implements Element { |
| return root; |
| } |
| - void shadowRootReady(ShadowRoot root, Element template) { |
| + void shadowRootReady(Node root, Element template) { |
|
Siggi Cherem (dart-lang)
2013/10/21 20:51:58
just wondering if this should be renamed (maybe a
Jennifer Messerly
2013/10/21 20:56:00
yeah it's a polymer.js question
https://github.com
|
| // locate nodes with id and store references to them in this.$ hash |
| marshalNodeReferences(root); |
| // add local events of interest... |
| @@ -237,7 +248,7 @@ abstract class Polymer implements Element { |
| } |
| /** Locate nodes with id and store references to them in [$] hash. */ |
| - void marshalNodeReferences(ShadowRoot root) { |
| + void marshalNodeReferences(Node root) { |
| if (root == null) return; |
| for (var n in root.queryAll('[id]')) { |
| $[n.id] = n; |
| @@ -588,7 +599,7 @@ abstract class Polymer implements Element { |
| } |
| /** Attach event listeners inside a shadow [root]. */ |
| - void addInstanceListeners(ShadowRoot root, Element template) { |
| + void addInstanceListeners(Node root, Element template) { |
| var templateDelegates = _declaration._templateDelegates; |
| if (templateDelegates == null) return; |
| var events = templateDelegates[template]; |