mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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:
parent
88f6d8d333
commit
ed5c15bf34
@ -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>
|
||||
Loading…
x
Reference in New Issue
Block a user