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

Side by Side Diff: pkg/template_binding/test/custom_element_bindings_test.dart

Issue 50203004: port TemplateBinding to ed3266266e751b5ab1f75f8e0509d0d5f0ef35d8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 library template_binding.test.custom_element_bindings_test; 5 library template_binding.test.custom_element_bindings_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'package:custom_element/polyfill.dart'; 9 import 'package:custom_element/polyfill.dart';
10 import 'package:template_binding/template_binding.dart'; 10 import 'package:template_binding/template_binding.dart';
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 '<my-custom-element my-point="{{a}}" scary-monster="{{b}}">' 117 '<my-custom-element my-point="{{a}}" scary-monster="{{b}}">'
118 '</my-custom-element>' 118 '</my-custom-element>'
119 '</template>'); 119 '</template>');
120 120
121 templateBind(div.query('template')).model = model; 121 templateBind(div.query('template')).model = model;
122 performMicrotaskCheckpoint(); 122 performMicrotaskCheckpoint();
123 123
124 var element = div.nodes[1]; 124 var element = div.nodes[1];
125 125
126 expect(element is MyCustomElement, true, 126 expect(element is MyCustomElement, true,
127 reason: '${element} should be a MyCustomElement'); 127 reason: '$element should be a MyCustomElement');
128 128
129 expect(element.myPoint, model['a']); 129 expect(element.myPoint, model['a']);
130 expect(element.scaryMonster, model['b']); 130 expect(element.scaryMonster, model['b']);
131 131
132 expect(element.attributes, isNot(contains('my-point'))); 132 expect(element.attributes, isNot(contains('my-point')));
133 expect(element.attributes, isNot(contains('scary-monster'))); 133 expect(element.attributes, isNot(contains('scary-monster')));
134 134
135 model['a'] = null; 135 model['a'] = null;
136 performMicrotaskCheckpoint(); 136 performMicrotaskCheckpoint();
137 expect(element.myPoint, null); 137 expect(element.myPoint, null);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 attributes.remove(name); 172 attributes.remove(name);
173 unbind(name); 173 unbind(name);
174 return bindings[name] = new _MyCustomBinding(this, name, model, path); 174 return bindings[name] = new _MyCustomBinding(this, name, model, path);
175 } 175 }
176 return nodeBindFallback(this).bind(name, model, path); 176 return nodeBindFallback(this).bind(name, model, path);
177 } 177 }
178 178
179 unbind(name) => nodeBindFallback(this).unbind(name); 179 unbind(name) => nodeBindFallback(this).unbind(name);
180 unbindAll() => nodeBindFallback(this).unbindAll(); 180 unbindAll() => nodeBindFallback(this).unbindAll();
181 get bindings => nodeBindFallback(this).bindings; 181 get bindings => nodeBindFallback(this).bindings;
182 get templateInstance => nodeBindFallback(this).templateInstance;
182 } 183 }
183 184
184 class _MyCustomBinding extends NodeBinding { 185 class _MyCustomBinding extends NodeBinding {
185 _MyCustomBinding(MyCustomElement node, property, model, path) 186 _MyCustomBinding(MyCustomElement node, property, model, path)
186 : super(node, property, model, path) { 187 : super(node, property, model, path) {
187 188
188 node.attributes.remove(property); 189 node.attributes.remove(property);
189 } 190 }
190 191
191 MyCustomElement get node => super.node; 192 MyCustomElement get node => super.node;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 240
240 void addAll(Map<K, V> other) => _map.addAll(other); 241 void addAll(Map<K, V> other) => _map.addAll(other);
241 void clear() => _map.clear(); 242 void clear() => _map.clear();
242 void forEach(void f(K key, V value)) => _map.forEach(f); 243 void forEach(void f(K key, V value)) => _map.forEach(f);
243 Iterable<K> get keys => _map.keys; 244 Iterable<K> get keys => _map.keys;
244 Iterable<V> get values => _map.values; 245 Iterable<V> get values => _map.values;
245 int get length => _map.length; 246 int get length => _map.length;
246 bool get isEmpty => _map.isEmpty; 247 bool get isEmpty => _map.isEmpty;
247 bool get isNotEmpty => _map.isNotEmpty; 248 bool get isNotEmpty => _map.isNotEmpty;
248 } 249 }
OLDNEW
« no previous file with comments | « pkg/template_binding/test/binding_syntax_test.dart ('k') | pkg/template_binding/test/node_bind_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698