| 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 | 13 |
| 14 static var attributeChangedInvocations = 0; | 14 static var attributeChangedInvocations = 0; |
| 15 | 15 |
| 16 void onAttributeChanged(name, oldValue, newValue) { | 16 void attributeChanged(name, oldValue, newValue) { |
| 17 attributeChangedInvocations++; | 17 attributeChangedInvocations++; |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 class B extends HtmlElement { | 21 class B extends HtmlElement { |
| 22 static final tag = 'x-b'; | 22 static final tag = 'x-b'; |
| 23 factory B() => new Element.tag(tag); | 23 factory B() => new Element.tag(tag); |
| 24 | 24 |
| 25 static var invocations = []; | 25 static var invocations = []; |
| 26 | 26 |
| 27 void onCreated() { | 27 void created() { |
| 28 invocations.add('created'); | 28 invocations.add('created'); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void onAttributeChanged(name, oldValue, newValue) { | 31 void attributeChanged(name, oldValue, newValue) { |
| 32 invocations.add('$name: $oldValue => $newValue'); | 32 invocations.add('$name: $oldValue => $newValue'); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 main() { | 36 main() { |
| 37 useHtmlConfiguration(); | 37 useHtmlConfiguration(); |
| 38 | 38 |
| 39 // Adapted from Blink's fast/dom/custom/attribute-changed-callback test. | 39 // Adapted from Blink's fast/dom/custom/attribute-changed-callback test. |
| 40 | 40 |
| 41 test('transfer attribute changed callback', () { | 41 test('transfer attribute changed callback', () { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 67 b.attributes['data-v'] = 'w'; | 67 b.attributes['data-v'] = 'w'; |
| 68 B.invocations = []; | 68 B.invocations = []; |
| 69 b.attributes['data-v'] = 'x'; | 69 b.attributes['data-v'] = 'x'; |
| 70 expect(B.invocations, ['data-v: w => x']); | 70 expect(B.invocations, ['data-v: w => x']); |
| 71 | 71 |
| 72 B.invocations = []; | 72 B.invocations = []; |
| 73 b.attributes['data-v'] = 'x'; | 73 b.attributes['data-v'] = 'x'; |
| 74 expect(B.invocations, []); | 74 expect(B.invocations, []); |
| 75 }); | 75 }); |
| 76 } | 76 } |
| OLD | NEW |