| 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 library polymer.polymer_element; | 5 library polymer.polymer_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
| 10 | 10 |
| 11 import 'package:custom_element/custom_element.dart'; |
| 11 import 'package:mdv/mdv.dart' as mdv; | 12 import 'package:mdv/mdv.dart' as mdv; |
| 12 import 'package:observe/observe.dart'; | 13 import 'package:observe/observe.dart'; |
| 13 | 14 |
| 14 import 'custom_element.dart'; | |
| 15 import 'observe.dart'; | 15 import 'observe.dart'; |
| 16 import 'src/utils_observe.dart' show toCamelCase, toHyphenedName; | 16 import 'src/utils_observe.dart' show toCamelCase, toHyphenedName; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Registers a [PolymerElement]. This is similar to [registerCustomElement] | 19 * Registers a [PolymerElement]. This is similar to [registerCustomElement] |
| 20 * but it is designed to work with the `<element>` element and adds additional | 20 * but it is designed to work with the `<element>` element and adds additional |
| 21 * features. | 21 * features. |
| 22 */ | 22 */ |
| 23 void registerPolymerElement(String localName, PolymerElement create()) { | 23 void registerPolymerElement(String localName, PolymerElement create()) { |
| 24 registerCustomElement(localName, () => create().._initialize(localName)); | 24 registerCustomElement(localName, () => create().._initialize(localName)); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 root.applyAuthorStyles = applyAuthorStyles; | 130 root.applyAuthorStyles = applyAuthorStyles; |
| 131 root.resetStyleInheritance = resetStyleInheritance; | 131 root.resetStyleInheritance = resetStyleInheritance; |
| 132 | 132 |
| 133 var templateNode = declaration.children.firstWhere( | 133 var templateNode = declaration.children.firstWhere( |
| 134 (n) => n.localName == 'template', orElse: () => null); | 134 (n) => n.localName == 'template', orElse: () => null); |
| 135 if (templateNode == null) return; | 135 if (templateNode == null) return; |
| 136 | 136 |
| 137 root.nodes.add(cloneTemplate(templateNode.content)); | 137 root.nodes.add(cloneTemplate(templateNode.content)); |
| 138 // TODO(sigmund): use fancy-syntax as the default. | 138 // TODO(sigmund): use fancy-syntax as the default. |
| 139 var syntax = templateNode.attributes['syntax']; | |
| 140 | |
| 141 // TODO(sigmund,jmesserly): mdv.bindModel should be async internally | 139 // TODO(sigmund,jmesserly): mdv.bindModel should be async internally |
| 142 Timer.run(() => mdv.bindModel(root, this, | 140 Timer.run(() => mdv.bindModel(root, this)); |
| 143 syntax != null ? TemplateElement.syntax[syntax] : null)); | |
| 144 } | 141 } |
| 145 } | 142 } |
| 146 | 143 |
| 147 void bind(String name, model, String path) { | 144 void bind(String name, model, String path) { |
| 148 var propObserver = _publishedAttrs[name]; | 145 var propObserver = _publishedAttrs[name]; |
| 149 if (propObserver != null) { | 146 if (propObserver != null) { |
| 150 unbind(name); | 147 unbind(name); |
| 151 | 148 |
| 152 _bindings[name] = new PathObserver(model, path).bindSync((value) { | 149 _bindings[name] = new PathObserver(model, path).bindSync((value) { |
| 153 propObserver.value = value; | 150 propObserver.value = value; |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 'onKeyMessage': MediaElement.keyMessageEvent, | 508 'onKeyMessage': MediaElement.keyMessageEvent, |
| 512 'onNeedKey': MediaElement.needKeyEvent, | 509 'onNeedKey': MediaElement.needKeyEvent, |
| 513 'onWebGlContextLost': CanvasElement.webGlContextLostEvent, | 510 'onWebGlContextLost': CanvasElement.webGlContextLostEvent, |
| 514 'onWebGlContextRestored': CanvasElement.webGlContextRestoredEvent, | 511 'onWebGlContextRestored': CanvasElement.webGlContextRestoredEvent, |
| 515 'onPointerLockChange': Document.pointerLockChangeEvent, | 512 'onPointerLockChange': Document.pointerLockChangeEvent, |
| 516 'onPointerLockError': Document.pointerLockErrorEvent, | 513 'onPointerLockError': Document.pointerLockErrorEvent, |
| 517 'onReadyStateChange': Document.readyStateChangeEvent, | 514 'onReadyStateChange': Document.readyStateChangeEvent, |
| 518 'onSelectionChange': Document.selectionChangeEvent, | 515 'onSelectionChange': Document.selectionChangeEvent, |
| 519 'onSecurityPolicyViolation': Document.securityPolicyViolationEvent, | 516 'onSecurityPolicyViolation': Document.securityPolicyViolationEvent, |
| 520 }; | 517 }; |
| OLD | NEW |