| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of polymer; | 5 part of polymer; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Use this annotation to publish a field as an attribute. For example: | 8 * Use this annotation to publish a field as an attribute. For example: |
| 9 * | 9 * |
| 10 * class MyPlaybackElement extends PolymerElement { | 10 * class MyPlaybackElement extends PolymerElement { |
| 11 * // This will be available as an HTML attribute, for example: | 11 * // This will be available as an HTML attribute, for example: |
| 12 * // <my-playback volume="11"> | 12 * // <my-playback volume="11"> |
| 13 * @published double volume; | 13 * @published double volume; |
| 14 * } | 14 * } |
| 15 */ | 15 */ |
| 16 // TODO(jmesserly): does @published imply @observable or vice versa? | 16 // TODO(jmesserly): does @published imply @observable or vice versa? |
| 17 const published = const PublishedProperty(); | 17 const published = const PublishedProperty(); |
| 18 | 18 |
| 19 /** An annotation used to publish a field as an attribute. See [published]. */ | 19 /** An annotation used to publish a field as an attribute. See [published]. */ |
| 20 class PublishedProperty extends ObservableProperty { | 20 class PublishedProperty extends ObservableProperty { |
| 21 const PublishedProperty(); | 21 const PublishedProperty(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * The mixin class for Polymer elements. It provides convenience features on top | 25 * The mixin class for Polymer elements. It provides convenience features on top |
| 26 * of the custom elements web standard. | 26 * of the custom elements web standard. |
| 27 */ | 27 */ |
| 28 abstract class Polymer implements Element { | 28 abstract class Polymer implements Element, Observable { |
| 29 // Fully ported from revision: | 29 // Fully ported from revision: |
| 30 // https://github.com/Polymer/polymer/blob/4dc481c11505991a7c43228d3797d28f212
67779 | 30 // https://github.com/Polymer/polymer/blob/4dc481c11505991a7c43228d3797d28f212
67779 |
| 31 // | 31 // |
| 32 // src/instance/attributes.js | 32 // src/instance/attributes.js |
| 33 // src/instance/base.js | 33 // src/instance/base.js |
| 34 // src/instance/events.js | 34 // src/instance/events.js |
| 35 // src/instance/mdv.js | 35 // src/instance/mdv.js |
| 36 // src/instance/properties.js | 36 // src/instance/properties.js |
| 37 // src/instance/utils.js | 37 // src/instance/utils.js |
| 38 // | 38 // |
| 39 // Not yet ported: | 39 // Not yet ported: |
| 40 // src/instance/style.js -- blocked on ShadowCSS.shimPolyfillDirectives | 40 // src/instance/style.js -- blocked on ShadowCSS.shimPolyfillDirectives |
| 41 | 41 |
| 42 | |
| 43 // TODO(jmesserly): should this really be public? | 42 // TODO(jmesserly): should this really be public? |
| 44 /** Regular expression that matches data-bindings. */ | 43 /** Regular expression that matches data-bindings. */ |
| 45 static final bindPattern = new RegExp(r'\{\{([^{}]*)}}'); | 44 static final bindPattern = new RegExp(r'\{\{([^{}]*)}}'); |
| 46 | 45 |
| 47 /** | 46 /** |
| 48 * Like [document.register] but for Polymer elements. | 47 * Like [document.register] but for Polymer elements. |
| 49 * | 48 * |
| 50 * Use the [name] to specify custom elment's tag name, for example: | 49 * Use the [name] to specify custom elment's tag name, for example: |
| 51 * "fancy-button" if the tag is used as `<fancy-button>`. | 50 * "fancy-button" if the tag is used as `<fancy-button>`. |
| 52 * | 51 * |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // add local events of interest... | 242 // add local events of interest... |
| 244 addInstanceListeners(root, template); | 243 addInstanceListeners(root, template); |
| 245 // TODO(jmesserly): port this | 244 // TODO(jmesserly): port this |
| 246 // set up pointer gestures | 245 // set up pointer gestures |
| 247 // PointerGestures.register(root); | 246 // PointerGestures.register(root); |
| 248 } | 247 } |
| 249 | 248 |
| 250 /** Locate nodes with id and store references to them in [$] hash. */ | 249 /** Locate nodes with id and store references to them in [$] hash. */ |
| 251 void marshalNodeReferences(Node root) { | 250 void marshalNodeReferences(Node root) { |
| 252 if (root == null) return; | 251 if (root == null) return; |
| 253 for (var n in root.queryAll('[id]')) { | 252 for (var n in (root as dynamic).queryAll('[id]')) { |
| 254 $[n.id] = n; | 253 $[n.id] = n; |
| 255 } | 254 } |
| 256 } | 255 } |
| 257 | 256 |
| 258 void attributeChanged(String name, String oldValue, String newValue) { | 257 void attributeChanged(String name, String oldValue, String newValue) { |
| 259 if (name != 'class' && name != 'style') { | 258 if (name != 'class' && name != 'style') { |
| 260 attributeToProperty(name, newValue); | 259 attributeToProperty(name, newValue); |
| 261 } | 260 } |
| 262 } | 261 } |
| 263 | 262 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 /** | 951 /** |
| 953 * Base class for PolymerElements deriving from HtmlElement. | 952 * Base class for PolymerElements deriving from HtmlElement. |
| 954 * | 953 * |
| 955 * See [Polymer]. | 954 * See [Polymer]. |
| 956 */ | 955 */ |
| 957 class PolymerElement extends HtmlElement with Polymer, Observable { | 956 class PolymerElement extends HtmlElement with Polymer, Observable { |
| 958 PolymerElement.created() : super.created() { | 957 PolymerElement.created() : super.created() { |
| 959 polymerCreated(); | 958 polymerCreated(); |
| 960 } | 959 } |
| 961 } | 960 } |
| OLD | NEW |