Make it possible to inherit from any constructable host object
This CL makes it possible for authors to extend any host object (e.g., DOM objects) and to use those objects in all the usual places they can be used in the API. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/936193005
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
CONSOLE: unittest-suite-wait-for-done
|
||||
CONSOLE: PASS: should be able to insert in DOM
|
||||
CONSOLE:
|
||||
CONSOLE: All 1 tests passed.
|
||||
CONSOLE: unittest-suite-success
|
||||
DONE
|
||||
31
engine/src/flutter/tests/dom/inherit-from-text.sky
Normal file
31
engine/src/flutter/tests/dom/inherit-from-text.sky
Normal file
@@ -0,0 +1,31 @@
|
||||
<sky>
|
||||
<script>
|
||||
import "../resources/third_party/unittest/unittest.dart";
|
||||
import "../resources/unit.dart";
|
||||
|
||||
import "dart:sky";
|
||||
|
||||
class CustomText extends Text {
|
||||
CustomText() : super("awesome");
|
||||
|
||||
bool get isCustom => true;
|
||||
}
|
||||
|
||||
void main() {
|
||||
initUnit();
|
||||
|
||||
test("should be able to insert in DOM", () {
|
||||
var child = new CustomText();
|
||||
expect(child.isCustom, isTrue);
|
||||
expect(child.parentNode, isNull);
|
||||
expect(child.data, equals("awesome"));
|
||||
|
||||
var parent = document.createElement("div");
|
||||
parent.appendChild(child);
|
||||
expect(child.parentNode, equals(parent));
|
||||
expect(parent.firstChild, equals(child));
|
||||
expect(parent.firstChild.isCustom, isTrue);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</sky>
|
||||
Reference in New Issue
Block a user