| 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 attribute_changed_callback_test; | 5 library attribute_changed_callback_test; |
| 6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
| 7 import 'package:unittest/html_config.dart'; | 7 import 'package:unittest/html_config.dart'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 | 9 |
| 10 class A extends HtmlElement { | 10 class A extends HtmlElement { |
| 11 static final tag = 'x-a'; | 11 static final tag = 'x-a'; |
| 12 factory A() => new Element.tag(tag); | 12 factory A() => new Element.tag(tag); |
| 13 A.created() : super.created(); | 13 A.created() : super.created(); |
| 14 | 14 |
| 15 static var attributeChangedInvocations = 0; | 15 static var attributeChangedInvocations = 0; |
| 16 | 16 |
| 17 void attributeChanged(name, oldValue, newValue) { | 17 void attributeChanged(name, oldValue, newValue) { |
| 18 attributeChangedInvocations++; | 18 attributeChangedInvocations++; |
| 19 } | 19 } |
| 20 } | 20 } |
| 21 | 21 |
| 22 class B extends HtmlElement { | 22 class B extends HtmlElement { |
| 23 static final tag = 'x-b'; | 23 static final tag = 'x-b'; |
| 24 factory B() => new Element.tag(tag); | 24 factory B() => new Element.tag(tag); |
| 25 B.created() : super.created(); | 25 B.created() : super.created(); |
| 26 | 26 |
| 27 static var invocations = []; | 27 static var invocations = []; |
| 28 | 28 |
| 29 void created() { | 29 void createdCallback() { |
| 30 invocations.add('created'); | 30 invocations.add('created'); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void attributeChanged(name, oldValue, newValue) { | 33 void attributeChanged(name, oldValue, newValue) { |
| 34 invocations.add('$name: $oldValue => $newValue'); | 34 invocations.add('$name: $oldValue => $newValue'); |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 | 37 |
| 38 main() { | 38 main() { |
| 39 useHtmlConfiguration(); | 39 useHtmlConfiguration(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 69 b.attributes['data-v'] = 'w'; | 69 b.attributes['data-v'] = 'w'; |
| 70 B.invocations = []; | 70 B.invocations = []; |
| 71 b.attributes['data-v'] = 'x'; | 71 b.attributes['data-v'] = 'x'; |
| 72 expect(B.invocations, ['data-v: w => x']); | 72 expect(B.invocations, ['data-v: w => x']); |
| 73 | 73 |
| 74 B.invocations = []; | 74 B.invocations = []; |
| 75 b.attributes['data-v'] = 'x'; | 75 b.attributes['data-v'] = 'x'; |
| 76 expect(B.invocations, []); | 76 expect(B.invocations, []); |
| 77 }); | 77 }); |
| 78 } | 78 } |
| OLD | NEW |