| 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 binding_syntax_test; | 5 library binding_syntax_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:html'; | 9 import 'dart:html'; |
| 10 import 'package:mdv_observe/mdv_observe.dart'; | 10 import 'package:mdv/mdv.dart' as mdv; |
| 11 import 'package:observe/observe.dart'; |
| 11 import 'package:unittest/html_config.dart'; | 12 import 'package:unittest/html_config.dart'; |
| 12 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
| 13 import 'mdv_observe_utils.dart'; | 14 import 'observe_utils.dart'; |
| 14 | 15 |
| 15 // Note: this file ported from | 16 // Note: this file ported from |
| 16 // https://github.com/toolkitchen/mdv/blob/master/tests/syntax.js | 17 // https://github.com/toolkitchen/mdv/blob/master/tests/syntax.js |
| 17 | 18 |
| 18 main() { | 19 main() { |
| 20 mdv.initialize(); |
| 19 useHtmlConfiguration(); | 21 useHtmlConfiguration(); |
| 20 group('Syntax', syntaxTests); | 22 group('Syntax', syntaxTests); |
| 21 } | 23 } |
| 22 | 24 |
| 23 syntaxTests() { | 25 syntaxTests() { |
| 24 var testDiv; | 26 var testDiv; |
| 25 | 27 |
| 26 setUp(() { | 28 setUp(() { |
| 27 document.body.append(testDiv = new DivElement()); | 29 document.body.append(testDiv = new DivElement()); |
| 28 }); | 30 }); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 class TimesTwoSyntax extends CustomBindingSyntax { | 255 class TimesTwoSyntax extends CustomBindingSyntax { |
| 254 getBinding(model, path, name, node) { | 256 getBinding(model, path, name, node) { |
| 255 path = path.trim(); | 257 path = path.trim(); |
| 256 if (!path.startsWith('2x:')) return null; | 258 if (!path.startsWith('2x:')) return null; |
| 257 | 259 |
| 258 path = path.substring(3); | 260 path = path.substring(3); |
| 259 return new CompoundBinding((values) => values['value'] * 2) | 261 return new CompoundBinding((values) => values['value'] * 2) |
| 260 ..bind('value', model, path); | 262 ..bind('value', model, path); |
| 261 } | 263 } |
| 262 } | 264 } |
| OLD | NEW |