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:
Adam Barth 2015-02-19 23:09:51 -08:00
parent 88f6d8d333
commit ed5c15bf34
2 changed files with 37 additions and 0 deletions

View File

@ -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

View 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>