| 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 | 14 |
| 14 static var attributeChangedInvocations = 0; | 15 static var attributeChangedInvocations = 0; |
| 15 | 16 |
| 16 void attributeChanged(name, oldValue, newValue) { | 17 void attributeChanged(name, oldValue, newValue) { |
| 17 attributeChangedInvocations++; | 18 attributeChangedInvocations++; |
| 18 } | 19 } |
| 19 } | 20 } |
| 20 | 21 |
| 21 class B extends HtmlElement { | 22 class B extends HtmlElement { |
| 22 static final tag = 'x-b'; | 23 static final tag = 'x-b'; |
| 23 factory B() => new Element.tag(tag); | 24 factory B() => new Element.tag(tag); |
| 25 B.created() : super.created(); |
| 24 | 26 |
| 25 static var invocations = []; | 27 static var invocations = []; |
| 26 | 28 |
| 27 void created() { | 29 void created() { |
| 28 invocations.add('created'); | 30 invocations.add('created'); |
| 29 } | 31 } |
| 30 | 32 |
| 31 void attributeChanged(name, oldValue, newValue) { | 33 void attributeChanged(name, oldValue, newValue) { |
| 32 invocations.add('$name: $oldValue => $newValue'); | 34 invocations.add('$name: $oldValue => $newValue'); |
| 33 } | 35 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 b.attributes['data-v'] = 'w'; | 69 b.attributes['data-v'] = 'w'; |
| 68 B.invocations = []; | 70 B.invocations = []; |
| 69 b.attributes['data-v'] = 'x'; | 71 b.attributes['data-v'] = 'x'; |
| 70 expect(B.invocations, ['data-v: w => x']); | 72 expect(B.invocations, ['data-v: w => x']); |
| 71 | 73 |
| 72 B.invocations = []; | 74 B.invocations = []; |
| 73 b.attributes['data-v'] = 'x'; | 75 b.attributes['data-v'] = 'x'; |
| 74 expect(B.invocations, []); | 76 expect(B.invocations, []); |
| 75 }); | 77 }); |
| 76 } | 78 } |
| OLD | NEW |