mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove all code relating to shadow trees, insertion points, shadow boundaries, traversing composed trees, distribution, template documents, custom elements, registering elements, element registries, element factories, shadow roots, etc. Remove the following features from the IDLs and from the binding generators: CustomElementCallbacks, Reflect*, EventHandler. Remove the CSS custom pseudo-element concept, since we no longer have a UA style sheet worth talking about, no longer have shadow trees or custom elements, no longer use pseudo-elements, and generally therefore don't use this code at all.
57 lines
2.0 KiB
Dart
57 lines
2.0 KiB
Dart
import "../resources/dom_utils.dart";
|
|
import "../resources/third_party/unittest/unittest.dart";
|
|
import "../resources/unit.dart";
|
|
|
|
import "dart:sky";
|
|
|
|
void main() {
|
|
initUnit();
|
|
|
|
var document = new Document();
|
|
|
|
test("should replace elements", () {
|
|
var parent = document.createElement("div");
|
|
var oldChild = parent.appendChild(document.createElement("div"));
|
|
var newChild = document.createElement("div");
|
|
oldChild.replaceWith([newChild]);
|
|
expect(oldChild.parentNode, isNull);
|
|
expect(newChild.parentNode, equals(parent));
|
|
});
|
|
|
|
test("should replace text", () {
|
|
var parent = document.createElement("div");
|
|
var oldChild = parent.appendChild(document.createText(" it's a text "));
|
|
var newChild = document.createElement("div");
|
|
oldChild.replaceWith([newChild]);
|
|
expect(oldChild.parentNode, isNull);
|
|
expect(newChild.parentNode, equals(parent));
|
|
});
|
|
|
|
test("should replace children with a fragment", () {
|
|
var fragment = document.createDocumentFragment();
|
|
var child1 = fragment.appendChild(document.createElement("div"));
|
|
var child2 = fragment.appendChild(document.createText(" text "));
|
|
var child3 = fragment.appendChild(document.createText(" "));
|
|
var child4 = fragment.appendChild(document.createElement("div"));
|
|
var parent = document.createElement("div");
|
|
var oldChild = parent.appendChild(document.createElement("div"));
|
|
var lastChild = parent.appendChild(document.createElement("div"));
|
|
oldChild.replaceWith([fragment]);
|
|
expect(child1.parentNode, equals(parent));
|
|
expect(child2.parentNode, equals(parent));
|
|
expect(child3.parentNode, equals(parent));
|
|
expect(child4.parentNode, equals(parent));
|
|
expect(oldChild.parentNode, isNull);
|
|
expect(childNodeCount(parent), equals(5));
|
|
expect(childElementCount(parent), equals(3));
|
|
expect(parent.lastChild, equals(lastChild));
|
|
});
|
|
|
|
// test("should throw when appending to a text", () {
|
|
// var parent = new Text();
|
|
// expect(() {
|
|
// parent.replaceChild(document.createElement("div"), null);
|
|
// }, throws);
|
|
// });
|
|
}
|