Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: sky/tests/custom-elements/callbacks.sky

Issue 943013002: Implement Custom Elements (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: attributeChanged***d***Callback Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <sky>
2 <script>
3 import "../resources/third_party/unittest/unittest.dart";
4 import "../resources/unit.dart";
5
6 import "dart:sky";
7
8 class FooElement extends Element {
9 FooElement() : super("foo");
10
11 attachedCallback() {
12 ++attachedCallbackCount;
13 }
14
15 detachedCallback() {
16 ++detachedCallbackCount;
17 }
18
19 attributeChangedCallback(String name, String oldValue, String newValue) {
20 ++attributeChangedCallbackCount;
21 }
22
23 int attachedCallbackCount = 0;
24 int detachedCallbackCount = 0;
25 int attributeChangedCallbackCount = 0;
26 }
27
28
29 void main() {
30 initUnit();
31
32 document.registerElement("foo", FooElement);
33
34 test("callbacks should be called", () {
35 Element sky = document.querySelector("sky");
36 FooElement foo = document.createElement("foo");
37 expect(foo.attachedCallbackCount, equals(0));
38 expect(foo.detachedCallbackCount, equals(0));
39 expect(foo.attributeChangedCallbackCount, equals(0));
40 sky.appendChild(foo);
41 expect(foo.attachedCallbackCount, equals(1));
42 expect(foo.detachedCallbackCount, equals(0));
43 expect(foo.attributeChangedCallbackCount, equals(0));
44 foo.setAttribute("bar", "baz");
45 expect(foo.attachedCallbackCount, equals(1));
46 expect(foo.detachedCallbackCount, equals(0));
47 expect(foo.attributeChangedCallbackCount, equals(1));
48 foo.remove();
49 expect(foo.attachedCallbackCount, equals(1));
50 expect(foo.detachedCallbackCount, equals(1));
51 expect(foo.attributeChangedCallbackCount, equals(1));
52 });
53 }
54 </script>
55 </sky>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698