| 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 template_binding.test.element_bindings_test; | 5 library template_binding.test.element_bindings_test; |
| 6 | 6 |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 import 'package:observe/observe.dart'; | 8 import 'package:observe/observe.dart'; |
| 9 import 'package:template_binding/template_binding.dart'; | 9 import 'package:template_binding/template_binding.dart'; |
| 10 import 'package:unittest/html_config.dart'; | 10 import 'package:unittest/html_config.dart'; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 observeTest('PlaceHolderBindingText', () { | 97 observeTest('PlaceHolderBindingText', () { |
| 98 var model = toObservable({ | 98 var model = toObservable({ |
| 99 'adj': 'cruel', | 99 'adj': 'cruel', |
| 100 'noun': 'world' | 100 'noun': 'world' |
| 101 }); | 101 }); |
| 102 | 102 |
| 103 var el = new DivElement(); | 103 var el = new DivElement(); |
| 104 el.text = 'dummy'; | 104 el.text = 'dummy'; |
| 105 el.nodes.first.text = 'Hello {{ adj }} {{noun}}!'; | 105 el.nodes.first.text = 'Hello {{ adj }} {{noun}}!'; |
| 106 var template = new Element.html('<template bind>'); | 106 var template = new Element.html('<template bind>'); |
| 107 template.content.append(el); | 107 templateBind(template).content.append(el); |
| 108 testDiv.append(template); | 108 testDiv.append(template); |
| 109 templateBind(template).model = model; | 109 templateBind(template).model = model; |
| 110 | 110 |
| 111 performMicrotaskCheckpoint(); | 111 performMicrotaskCheckpoint(); |
| 112 el = testDiv.nodes[1].nodes.first; | 112 el = testDiv.nodes[1].nodes.first; |
| 113 expect(el.text, 'Hello cruel world!'); | 113 expect(el.text, 'Hello cruel world!'); |
| 114 | 114 |
| 115 model['adj'] = 'happy'; | 115 model['adj'] = 'happy'; |
| 116 performMicrotaskCheckpoint(); | 116 performMicrotaskCheckpoint(); |
| 117 expect(el.text, 'Hello happy world!'); | 117 expect(el.text, 'Hello happy world!'); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 expect(select.selectedIndex, 2); | 376 expect(select.selectedIndex, 2); |
| 377 | 377 |
| 378 select.selectedIndex = 1; | 378 select.selectedIndex = 1; |
| 379 dispatchEvent('change', select); | 379 dispatchEvent('change', select); |
| 380 expect(model['val'], 1); | 380 expect(model['val'], 1); |
| 381 }); | 381 }); |
| 382 | 382 |
| 383 observeTest('MultipleReferences', () { | 383 observeTest('MultipleReferences', () { |
| 384 var el = new DivElement(); | 384 var el = new DivElement(); |
| 385 var template = new Element.html('<template bind>'); | 385 var template = new Element.html('<template bind>'); |
| 386 template.content.append(el); | 386 templateBind(template).content.append(el); |
| 387 testDiv.append(template); | 387 testDiv.append(template); |
| 388 | 388 |
| 389 var model = toObservable({'foo': 'bar'}); | 389 var model = toObservable({'foo': 'bar'}); |
| 390 el.attributes['foo'] = '{{foo}} {{foo}}'; | 390 el.attributes['foo'] = '{{foo}} {{foo}}'; |
| 391 templateBind(template).model = model; | 391 templateBind(template).model = model; |
| 392 | 392 |
| 393 performMicrotaskCheckpoint(); | 393 performMicrotaskCheckpoint(); |
| 394 el = testDiv.nodes[1]; | 394 el = testDiv.nodes[1]; |
| 395 expect(el.attributes['foo'], 'bar bar'); | 395 expect(el.attributes['foo'], 'bar bar'); |
| 396 }); | 396 }); |
| 397 } | 397 } |
| OLD | NEW |