mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This CL ports sky-scrollable to the new sky-element. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/950603002
56 lines
1.5 KiB
Plaintext
56 lines
1.5 KiB
Plaintext
<sky>
|
|
<script>
|
|
import "../resources/third_party/unittest/unittest.dart";
|
|
import "../resources/unit.dart";
|
|
|
|
import "dart:sky";
|
|
|
|
class FooElement extends Element {
|
|
final String tagName = "foo";
|
|
|
|
attachedCallback() {
|
|
++attachedCallbackCount;
|
|
}
|
|
|
|
detachedCallback() {
|
|
++detachedCallbackCount;
|
|
}
|
|
|
|
attributeChangedCallback(String name, String oldValue, String newValue) {
|
|
++attributeChangedCallbackCount;
|
|
}
|
|
|
|
int attachedCallbackCount = 0;
|
|
int detachedCallbackCount = 0;
|
|
int attributeChangedCallbackCount = 0;
|
|
}
|
|
|
|
|
|
void main() {
|
|
initUnit();
|
|
|
|
document.registerElement("foo", FooElement);
|
|
|
|
test("callbacks should be called", () {
|
|
Element sky = document.querySelector("sky");
|
|
FooElement foo = document.createElement("foo");
|
|
expect(foo.attachedCallbackCount, equals(0));
|
|
expect(foo.detachedCallbackCount, equals(0));
|
|
expect(foo.attributeChangedCallbackCount, equals(0));
|
|
sky.appendChild(foo);
|
|
expect(foo.attachedCallbackCount, equals(1));
|
|
expect(foo.detachedCallbackCount, equals(0));
|
|
expect(foo.attributeChangedCallbackCount, equals(0));
|
|
foo.setAttribute("bar", "baz");
|
|
expect(foo.attachedCallbackCount, equals(1));
|
|
expect(foo.detachedCallbackCount, equals(0));
|
|
expect(foo.attributeChangedCallbackCount, equals(1));
|
|
foo.remove();
|
|
expect(foo.attachedCallbackCount, equals(1));
|
|
expect(foo.detachedCallbackCount, equals(1));
|
|
expect(foo.attributeChangedCallbackCount, equals(1));
|
|
});
|
|
}
|
|
</script>
|
|
</sky>
|