| 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 node_bindings_test; | 5 library node_bindings_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:mdv/mdv.dart' as mdv; | 9 import 'package:mdv/mdv.dart' as mdv; |
| 10 import 'package:observe/observe.dart'; | 10 import 'package:observe/observe.dart'; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 model[sym('val')] = false; | 183 model[sym('val')] = false; |
| 184 deliverChangeRecords(); | 184 deliverChangeRecords(); |
| 185 expect(el.checked, false); | 185 expect(el.checked, false); |
| 186 | 186 |
| 187 el.click(); | 187 el.click(); |
| 188 expect(model[sym('val')], true); | 188 expect(model[sym('val')], true); |
| 189 | 189 |
| 190 el.click(); | 190 el.click(); |
| 191 expect(model[sym('val')], false); | 191 expect(model[sym('val')], false); |
| 192 |
| 193 el.onClick.listen((_) { |
| 194 expect(model[sym('val')], true); |
| 195 }); |
| 196 el.onChange.listen((_) { |
| 197 expect(model[sym('val')], true); |
| 198 }); |
| 199 |
| 200 el.dispatchEvent(new MouseEvent('click', view: window)); |
| 192 }); | 201 }); |
| 193 | 202 |
| 203 test('InputElementCheckbox - binding updated on click', () { |
| 204 var model = toSymbolMap({'val': true}); |
| 205 |
| 206 var el = new InputElement(); |
| 207 testDiv.append(el); |
| 208 el.type = 'checkbox'; |
| 209 el.bind('checked', model, 'val'); |
| 210 deliverChangeRecords(); |
| 211 expect(el.checked, true); |
| 212 |
| 213 el.onClick.listen((_) { |
| 214 expect(model[sym('val')], false); |
| 215 }); |
| 216 |
| 217 el.dispatchEvent(new MouseEvent('click', view: window)); |
| 218 }); |
| 219 |
| 220 test('InputElementCheckbox - binding updated on change', () { |
| 221 var model = toSymbolMap({'val': true}); |
| 222 |
| 223 var el = new InputElement(); |
| 224 testDiv.append(el); |
| 225 el.type = 'checkbox'; |
| 226 el.bind('checked', model, 'val'); |
| 227 deliverChangeRecords(); |
| 228 expect(el.checked, true); |
| 229 |
| 230 el.onChange.listen((_) { |
| 231 expect(model[sym('val')], false); |
| 232 }); |
| 233 |
| 234 el.dispatchEvent(new MouseEvent('click', view: window)); |
| 235 }); |
| 236 |
| 194 test('InputElementRadio', () { | 237 test('InputElementRadio', () { |
| 195 var model = toSymbolMap({'val1': true, 'val2': false, 'val3': false, | 238 var model = toSymbolMap({'val1': true, 'val2': false, 'val3': false, |
| 196 'val4': true}); | 239 'val4': true}); |
| 197 var RADIO_GROUP_NAME = 'test'; | 240 var RADIO_GROUP_NAME = 'test'; |
| 198 | 241 |
| 199 var container = testDiv; | 242 var container = testDiv; |
| 200 | 243 |
| 201 var el1 = new InputElement(); | 244 var el1 = new InputElement(); |
| 202 testDiv.append(el1); | 245 testDiv.append(el1); |
| 203 el1.type = 'radio'; | 246 el1.type = 'radio'; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 380 |
| 338 var model = toSymbolMap({'foo': 'bar'}); | 381 var model = toSymbolMap({'foo': 'bar'}); |
| 339 el.attributes['foo'] = '{{foo}} {{foo}}'; | 382 el.attributes['foo'] = '{{foo}} {{foo}}'; |
| 340 template.model = model; | 383 template.model = model; |
| 341 | 384 |
| 342 deliverChangeRecords(); | 385 deliverChangeRecords(); |
| 343 el = testDiv.nodes[1]; | 386 el = testDiv.nodes[1]; |
| 344 expect(el.attributes['foo'], 'bar bar'); | 387 expect(el.attributes['foo'], 'bar bar'); |
| 345 }); | 388 }); |
| 346 } | 389 } |
| OLD | NEW |