Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: pkg/polymer/lib/src/instance.dart

Issue 507653004: update polymer to 0.3.5 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review updates Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/polymer/lib/src/events.dart ('k') | pkg/polymer/lib/src/js/polymer/build.log » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 property as an attribute. 7 /// Use this annotation to publish a property 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 /// 345 ///
346 /// If this class is a superclass, calling `super.created()` is sufficient. 346 /// If this class is a superclass, calling `super.created()` is sufficient.
347 void polymerCreated() { 347 void polymerCreated() {
348 var t = nodeBind(this).templateInstance; 348 var t = nodeBind(this).templateInstance;
349 if (t != null && t.model != null) { 349 if (t != null && t.model != null) {
350 window.console.warn('Attributes on $_name were data bound ' 350 window.console.warn('Attributes on $_name were data bound '
351 'prior to Polymer upgrading the element. This may result in ' 351 'prior to Polymer upgrading the element. This may result in '
352 'incorrect binding types.'); 352 'incorrect binding types.');
353 } 353 }
354 prepareElement(); 354 prepareElement();
355 355 if (!isTemplateStagingDocument(ownerDocument)) {
356 // TODO(sorvell): replace when ShadowDOMPolyfill issue is corrected
357 // https://github.com/Polymer/ShadowDOM/issues/420
358 if (!isTemplateStagingDocument(ownerDocument) || _hasShadowDomPolyfill) {
359 makeElementReady(); 356 makeElementReady();
360 } 357 }
361 } 358 }
362 359
363 /// *Deprecated* use [shadowRoots] instead. 360 /// *Deprecated* use [shadowRoots] instead.
364 @deprecated 361 @deprecated
365 ShadowRoot getShadowRoot(String customTagName) => shadowRoots[customTagName]; 362 ShadowRoot getShadowRoot(String customTagName) => shadowRoots[customTagName];
366 363
367 void prepareElement() { 364 void prepareElement() {
368 if (_elementPrepared) { 365 if (_elementPrepared) {
369 window.console.warn('Element already prepared: $_name'); 366 window.console.warn('Element already prepared: $_name');
370 return; 367 return;
371 } 368 }
372 _initJsObject(); 369 _initJsObject();
373 // Dart note: get the corresponding <polymer-element> declaration. 370 // Dart note: get the corresponding <polymer-element> declaration.
374 _element = _getDeclaration(_name); 371 _element = _getDeclaration(_name);
375 // install property storage 372 // install property storage
376 createPropertyObserver(); 373 createPropertyObserver();
377 // TODO (sorvell): temporarily open observer when created
378 openPropertyObserver(); 374 openPropertyObserver();
379 // install boilerplate attributes 375 // install boilerplate attributes
380 copyInstanceAttributes(); 376 copyInstanceAttributes();
381 // process input attributes 377 // process input attributes
382 takeAttributes(); 378 takeAttributes();
383 // add event listeners 379 // add event listeners
384 addHostListeners(); 380 addHostListeners();
385 } 381 }
386 382
387 /// Initialize JS interop for this element. For now we just initialize the 383 /// Initialize JS interop for this element. For now we just initialize the
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 root.append(dom); 513 root.append(dom);
518 // perform post-construction initialization tasks on shadow root 514 // perform post-construction initialization tasks on shadow root
519 shadowRootReady(root); 515 shadowRootReady(root);
520 // return the created shadow root 516 // return the created shadow root
521 return root; 517 return root;
522 } 518 }
523 519
524 void shadowRootReady(Node root) { 520 void shadowRootReady(Node root) {
525 // locate nodes with id and store references to them in this.$ hash 521 // locate nodes with id and store references to them in this.$ hash
526 marshalNodeReferences(root); 522 marshalNodeReferences(root);
527
528 // set up polymer gestures
529 if (_PolymerGestures != null) {
530 _PolymerGestures.callMethod('register', [root]);
531 }
532 } 523 }
533 524
534 /// Locate nodes with id and store references to them in [$] hash. 525 /// Locate nodes with id and store references to them in [$] hash.
535 void marshalNodeReferences(Node root) { 526 void marshalNodeReferences(Node root) {
536 if (root == null) return; 527 if (root == null) return;
537 for (var n in (root as dynamic).querySelectorAll('[id]')) { 528 for (var n in (root as dynamic).querySelectorAll('[id]')) {
538 $[n.id] = n; 529 $[n.id] = n;
539 } 530 }
540 } 531 }
541 532
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 if (events.isEmpty) return; 1010 if (events.isEmpty) return;
1020 1011
1021 _eventsLog.fine(() => '[$_name] addHostListeners: $events'); 1012 _eventsLog.fine(() => '[$_name] addHostListeners: $events');
1022 1013
1023 // NOTE: host events look like bindings but really are not; 1014 // NOTE: host events look like bindings but really are not;
1024 // (1) we don't want the attribute to be set and (2) we want to support 1015 // (1) we don't want the attribute to be set and (2) we want to support
1025 // multiple event listeners ('host' and 'instance') and Node.bind 1016 // multiple event listeners ('host' and 'instance') and Node.bind
1026 // by default supports 1 thing being bound. 1017 // by default supports 1 thing being bound.
1027 events.forEach((type, methodName) { 1018 events.forEach((type, methodName) {
1028 // Dart note: the getEventHandler method is on our PolymerExpressions. 1019 // Dart note: the getEventHandler method is on our PolymerExpressions.
1029 on[type].listen(element.syntax.getEventHandler(this, this, methodName)); 1020 _PolymerGestures.callMethod(
1021 'addEventListener',
1022 [this, type, Zone.current.bindUnaryCallback(
1023 element.syntax.getEventHandler(this, this, methodName))]);
1030 }); 1024 });
1031 } 1025 }
1032 1026
1033 /// Calls [methodOrCallback] with [args] if it is a closure, otherwise, treat 1027 /// Calls [methodOrCallback] with [args] if it is a closure, otherwise, treat
1034 /// it as a method name in [object], and invoke it. 1028 /// it as a method name in [object], and invoke it.
1035 void dispatchMethod(object, callbackOrMethod, List args) { 1029 void dispatchMethod(object, callbackOrMethod, List args) {
1036 _eventsLog.info(() => '>>> [$_name]: dispatch $callbackOrMethod'); 1030 _eventsLog.info(() => '>>> [$_name]: dispatch $callbackOrMethod');
1037 1031
1038 if (callbackOrMethod is Function) { 1032 if (callbackOrMethod is Function) {
1039 int maxArgs = smoke.maxArgs(callbackOrMethod); 1033 int maxArgs = smoke.maxArgs(callbackOrMethod);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 installScopeCssText('$cssText', scope, name); 1160 installScopeCssText('$cssText', scope, name);
1167 } 1161 }
1168 } 1162 }
1169 1163
1170 void installScopeCssText(String cssText, [Node scope, String name]) { 1164 void installScopeCssText(String cssText, [Node scope, String name]) {
1171 if (scope == null) scope = findStyleScope(); 1165 if (scope == null) scope = findStyleScope();
1172 if (name == null) name = ''; 1166 if (name == null) name = '';
1173 1167
1174 if (scope == null) return; 1168 if (scope == null) return;
1175 1169
1176 if (_ShadowCss != null) { 1170 if (_hasShadowDomPolyfill) {
1177 cssText = _shimCssText(cssText, scope is ShadowRoot ? scope.host : null); 1171 cssText = _shimCssText(cssText, scope is ShadowRoot ? scope.host : null);
1178 } 1172 }
1179 var style = element.cssTextToScopeStyle(cssText, 1173 var style = element.cssTextToScopeStyle(cssText,
1180 _STYLE_CONTROLLER_SCOPE); 1174 _STYLE_CONTROLLER_SCOPE);
1181 applyStyleToScope(style, scope); 1175 applyStyleToScope(style, scope);
1182 // cache that this style has been applied 1176 // cache that this style has been applied
1183 styleCacheForScope(scope).add('$_name$name'); 1177 styleCacheForScope(scope).add('$_name$name');
1184 } 1178 }
1185 1179
1186 Node findStyleScope([node]) { 1180 Node findStyleScope([node]) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 final Logger _eventsLog = new Logger('polymer.events'); 1344 final Logger _eventsLog = new Logger('polymer.events');
1351 final Logger _unbindLog = new Logger('polymer.unbind'); 1345 final Logger _unbindLog = new Logger('polymer.unbind');
1352 final Logger _bindLog = new Logger('polymer.bind'); 1346 final Logger _bindLog = new Logger('polymer.bind');
1353 final Logger _watchLog = new Logger('polymer.watch'); 1347 final Logger _watchLog = new Logger('polymer.watch');
1354 final Logger _readyLog = new Logger('polymer.ready'); 1348 final Logger _readyLog = new Logger('polymer.ready');
1355 1349
1356 final Expando _eventHandledTable = new Expando<Set<Node>>(); 1350 final Expando _eventHandledTable = new Expando<Set<Node>>();
1357 1351
1358 final JsObject _PolymerGestures = js.context['PolymerGestures']; 1352 final JsObject _PolymerGestures = js.context['PolymerGestures'];
1359 1353
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/events.dart ('k') | pkg/polymer/lib/src/js/polymer/build.log » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698