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

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

Issue 26660004: Updating todomvc for some polymer changes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
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 /** 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 {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 _unbindLog.info('[$localName] cancelUnbindAll'); 425 _unbindLog.info('[$localName] cancelUnbindAll');
426 if (_unbindAllJob != null) { 426 if (_unbindAllJob != null) {
427 _unbindAllJob.stop(); 427 _unbindAllJob.stop();
428 _unbindAllJob = null; 428 _unbindAllJob = null;
429 } 429 }
430 430
431 // cancel unbinding our shadow tree iff we're not in the process of 431 // cancel unbinding our shadow tree iff we're not in the process of
432 // cascading our tree (as we do, for example, when the element is inserted). 432 // cascading our tree (as we do, for example, when the element is inserted).
433 if (preventCascade == true) return; 433 if (preventCascade == true) return;
434 _forNodeTree(shadowRoot, (n) { 434 _forNodeTree(shadowRoot, (n) {
435 if (n is PolymerElement) { 435 if (n is Polymer) {
436 (n as PolymerElement).cancelUnbindAll(); 436 (n as Polymer).cancelUnbindAll();
437 } 437 }
438 }); 438 });
439 } 439 }
440 440
441 static void _unbindNodeTree(Node node) { 441 static void _unbindNodeTree(Node node) {
442 _forNodeTree(node, (node) => node.unbindAll()); 442 _forNodeTree(node, (node) => node.unbindAll());
443 } 443 }
444 444
445 static void _forNodeTree(Node node, void callback(Node node)) { 445 static void _forNodeTree(Node node, void callback(Node node)) {
446 if (node == null) return; 446 if (node == null) return;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 // TODO(jmesserly): replace with something more localized, like: 545 // TODO(jmesserly): replace with something more localized, like:
546 // @ComputedField('myModel.path.to.otherProp'); 546 // @ComputedField('myModel.path.to.otherProp');
547 NodeBinding bindProperty(Symbol name, Object model, String path) => 547 NodeBinding bindProperty(Symbol name, Object model, String path) =>
548 // apply Polymer two-way reference binding 548 // apply Polymer two-way reference binding
549 _bindProperties(this, name, model, path); 549 _bindProperties(this, name, model, path);
550 550
551 /** 551 /**
552 * bind a property in A to a path in B by converting A[property] to a 552 * bind a property in A to a path in B by converting A[property] to a
553 * getter/setter pair that accesses B[...path...] 553 * getter/setter pair that accesses B[...path...]
554 */ 554 */
555 static NodeBinding _bindProperties(PolymerElement inA, Symbol inProperty, 555 static NodeBinding _bindProperties(Polymer inA, Symbol inProperty,
556 Object inB, String inPath) { 556 Object inB, String inPath) {
557 557
558 if (_bindLog.isLoggable(Level.INFO)) { 558 if (_bindLog.isLoggable(Level.INFO)) {
559 _bindLog.info('[$inB]: bindProperties: [$inPath] to ' 559 _bindLog.info('[$inB]: bindProperties: [$inPath] to '
560 '[${inA.localName}].[$inProperty]'); 560 '[${inA.localName}].[$inProperty]');
561 } 561 }
562 562
563 // Dart note: normally we only reach this code when we know it's a 563 // Dart note: normally we only reach this code when we know it's a
564 // property, but if someone uses bindProperty directly they might get a 564 // property, but if someone uses bindProperty directly they might get a
565 // NoSuchMethodError either from the getField below, or from the setField 565 // NoSuchMethodError either from the getField below, or from the setField
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 // model@path. We can't replicate this in Dart so we do the next best thing: 860 // model@path. We can't replicate this in Dart so we do the next best thing:
861 // listen to changes on both sides and update the values. 861 // listen to changes on both sides and update the values.
862 // TODO(jmesserly): our approach leads to race conditions in the bindings. 862 // TODO(jmesserly): our approach leads to race conditions in the bindings.
863 // See http://code.google.com/p/dart/issues/detail?id=13567 863 // See http://code.google.com/p/dart/issues/detail?id=13567
864 class _PolymerBinding extends NodeBinding { 864 class _PolymerBinding extends NodeBinding {
865 final InstanceMirror _target; 865 final InstanceMirror _target;
866 final Symbol _property; 866 final Symbol _property;
867 StreamSubscription _sub; 867 StreamSubscription _sub;
868 Object _lastValue; 868 Object _lastValue;
869 869
870 _PolymerBinding(PolymerElement node, Symbol property, model, path) 870 _PolymerBinding(Polymer node, Symbol property, model, path)
871 : _target = reflect(node), 871 : _target = reflect(node),
872 _property = property, 872 _property = property,
873 super(node, MirrorSystem.getName(property), model, path) { 873 super(node, MirrorSystem.getName(property), model, path) {
874 874
875 _sub = node.changes.listen(_propertyValueChanged); 875 _sub = node.changes.listen(_propertyValueChanged);
876 } 876 }
877 877
878 void close() { 878 void close() {
879 if (closed) return; 879 if (closed) return;
880 _sub.cancel(); 880 _sub.cancel();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 /** 930 /**
931 * Base class for PolymerElements deriving from HtmlElement. 931 * Base class for PolymerElements deriving from HtmlElement.
932 * 932 *
933 * See [Polymer]. 933 * See [Polymer].
934 */ 934 */
935 class PolymerElement extends HtmlElement with Polymer, ObservableMixin { 935 class PolymerElement extends HtmlElement with Polymer, ObservableMixin {
936 PolymerElement.created() : super.created() { 936 PolymerElement.created() : super.created() {
937 polymerCreated(); 937 polymerCreated();
938 } 938 }
939 } 939 }
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer/test/take_attributes_test.dart » ('j') | pkg/polymer/test/take_attributes_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698