Chromium Code Reviews| 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 /// Use this annotation to publish a field as an attribute. | 7 /// Use this annotation to publish a field as an attribute. |
| 8 /// | 8 /// |
| 9 /// You can also use [PublishedProperty] to provide additional information, | 9 /// You can also use [PublishedProperty] to provide additional information, |
| 10 /// such as automatically syncing the property back to the attribute. | 10 /// such as automatically syncing the property back to the attribute. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 | 175 |
| 176 Map<String, StreamSubscription> _namedObservers; | 176 Map<String, StreamSubscription> _namedObservers; |
| 177 List<Iterable<Bindable>> _observers = []; | 177 List<Iterable<Bindable>> _observers = []; |
| 178 | 178 |
| 179 bool _unbound; // lazy-initialized | 179 bool _unbound; // lazy-initialized |
| 180 PolymerJob _unbindAllJob; | 180 PolymerJob _unbindAllJob; |
| 181 | 181 |
| 182 CompoundObserver _propertyObserver; | 182 CompoundObserver _propertyObserver; |
| 183 bool _readied = false; | 183 bool _readied = false; |
| 184 | 184 |
| 185 JsObject _jsElem; | |
| 186 | |
| 185 /// Returns the object that should be used as the event controller for | 187 /// Returns the object that should be used as the event controller for |
| 186 /// event bindings in this element's template. If set, this will override the | 188 /// event bindings in this element's template. If set, this will override the |
| 187 /// normal controller lookup. | 189 /// normal controller lookup. |
| 188 // TODO(jmesserly): type seems wrong here? I'm guessing this should be any | 190 // TODO(jmesserly): we need to use a JS-writable property as our backing |
| 189 // kind of model object. Also, should it be writable by anyone? | 191 // store, because of elements such as: |
| 190 Polymer eventController; | 192 // https://github.com/Polymer/core-overlay/blob/eeb14853/core-overlay-layer.ht ml#L78 |
| 193 get eventController => _jsElem['eventController']; | |
| 194 set eventController(value) { _jsElem['eventController'] = value; } | |
|
Siggi Cherem (dart-lang)
2014/06/18 01:51:42
woah!
Should we add the type annotation here? Mai
Jennifer Messerly
2014/06/18 02:18:47
Hmmm. We could put back Element, which is what Pol
| |
| 191 | 195 |
| 192 bool get hasBeenAttached => _hasBeenAttached; | 196 bool get hasBeenAttached => _hasBeenAttached; |
| 193 bool _hasBeenAttached = false; | 197 bool _hasBeenAttached = false; |
| 194 | 198 |
| 195 /// Gets the shadow root associated with the corresponding custom element. | 199 /// Gets the shadow root associated with the corresponding custom element. |
| 196 /// | 200 /// |
| 197 /// This is identical to [shadowRoot], unless there are multiple levels of | 201 /// This is identical to [shadowRoot], unless there are multiple levels of |
| 198 /// inheritance and they each have their own shadow root. For example, | 202 /// inheritance and they each have their own shadow root. For example, |
| 199 /// this can happen if the base class and subclass both have `<template>` tags | 203 /// this can happen if the base class and subclass both have `<template>` tags |
| 200 /// in their `<polymer-element>` tags. | 204 /// in their `<polymer-element>` tags. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 | 260 |
| 257 /// *Deprecated* use [shadowRoots] instead. | 261 /// *Deprecated* use [shadowRoots] instead. |
| 258 @deprecated | 262 @deprecated |
| 259 ShadowRoot getShadowRoot(String customTagName) => shadowRoots[customTagName]; | 263 ShadowRoot getShadowRoot(String customTagName) => shadowRoots[customTagName]; |
| 260 | 264 |
| 261 void prepareElement() { | 265 void prepareElement() { |
| 262 if (_elementPrepared) { | 266 if (_elementPrepared) { |
| 263 window.console.warn('Element already prepared: $_name'); | 267 window.console.warn('Element already prepared: $_name'); |
| 264 return; | 268 return; |
| 265 } | 269 } |
| 270 _initJsObject(); | |
| 266 // Dart note: get the corresponding <polymer-element> declaration. | 271 // Dart note: get the corresponding <polymer-element> declaration. |
| 267 _element = _getDeclaration(_name); | 272 _element = _getDeclaration(_name); |
| 268 // install property storage | 273 // install property storage |
| 269 createPropertyObserver(); | 274 createPropertyObserver(); |
| 270 // TODO (sorvell): temporarily open observer when created | 275 // TODO (sorvell): temporarily open observer when created |
| 271 openPropertyObserver(); | 276 openPropertyObserver(); |
| 272 // install boilerplate attributes | 277 // install boilerplate attributes |
| 273 copyInstanceAttributes(); | 278 copyInstanceAttributes(); |
| 274 // process input attributes | 279 // process input attributes |
| 275 takeAttributes(); | 280 takeAttributes(); |
| 276 // add event listeners | 281 // add event listeners |
| 277 addHostListeners(); | 282 addHostListeners(); |
| 278 } | 283 } |
| 279 | 284 |
| 285 /// Initialize JS interop for this element. For now we just initialize the | |
| 286 // JsObject, but in the future we could also initialize JS APIs here. | |
| 287 _initJsObject() { | |
| 288 _jsElem = new JsObject.fromBrowserObject(this); | |
| 289 } | |
| 290 | |
| 280 makeElementReady() { | 291 makeElementReady() { |
| 281 if (_readied) return; | 292 if (_readied) return; |
| 282 _readied = true; | 293 _readied = true; |
| 283 | 294 |
| 284 // TODO(sorvell): We could create an entry point here | 295 // TODO(sorvell): We could create an entry point here |
| 285 // for the user to compute property values. | 296 // for the user to compute property values. |
| 286 // process declarative resources | 297 // process declarative resources |
| 287 parseDeclarations(_element); | 298 parseDeclarations(_element); |
| 288 // TODO(sorvell): CE polyfill uses unresolved attribute to simulate | 299 // TODO(sorvell): CE polyfill uses unresolved attribute to simulate |
| 289 // :unresolved; remove this attribute to be compatible with native | 300 // :unresolved; remove this attribute to be compatible with native |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1117 | 1128 |
| 1118 final Logger _observeLog = new Logger('polymer.observe'); | 1129 final Logger _observeLog = new Logger('polymer.observe'); |
| 1119 final Logger _eventsLog = new Logger('polymer.events'); | 1130 final Logger _eventsLog = new Logger('polymer.events'); |
| 1120 final Logger _unbindLog = new Logger('polymer.unbind'); | 1131 final Logger _unbindLog = new Logger('polymer.unbind'); |
| 1121 final Logger _bindLog = new Logger('polymer.bind'); | 1132 final Logger _bindLog = new Logger('polymer.bind'); |
| 1122 | 1133 |
| 1123 final Expando _eventHandledTable = new Expando<Set<Node>>(); | 1134 final Expando _eventHandledTable = new Expando<Set<Node>>(); |
| 1124 | 1135 |
| 1125 final JsObject _PolymerGestures = js.context['PolymerGestures']; | 1136 final JsObject _PolymerGestures = js.context['PolymerGestures']; |
| 1126 | 1137 |
| OLD | NEW |