Fix warnings seen when running skyanalyzer in strong mode

This commit is contained in:
Jason Simmons
2015-10-13 16:04:12 -07:00
parent 6e91cfa49a
commit 5b72a2fdaf
39 changed files with 219 additions and 206 deletions

View File

@@ -6,15 +6,15 @@ void main() {
Document document = new Document();
test("should throw with invalid arguments", () {
var parent = document.createElement("div");
var child = document.createElement("div");
Element parent = document.createElement("div");
Element child = document.createElement("div");
parent.appendChild(child);
// TODO(eseidel): This should throw!
// expect(() {
// parent.insertBefore([parent]);
// }, throws);
expect(() {
child.insertBefore([parent]);
child.insertBefore(<Node>[parent]);
}, throws);
});

View File

@@ -5,36 +5,36 @@ import 'package:test/test.dart';
import 'dom_utils.dart';
void main() {
var document = new Document();
Document 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]);
Element parent = document.createElement("div");
Element oldChild = parent.appendChild(document.createElement("div"));
Element newChild = document.createElement("div");
oldChild.replaceWith(<Node>[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]);
Element parent = document.createElement("div");
Node oldChild = parent.appendChild(document.createText(" it's a text "));
Element newChild = document.createElement("div");
oldChild.replaceWith(<Node>[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]);
DocumentFragment fragment = document.createDocumentFragment();
Element child1 = fragment.appendChild(document.createElement("div"));
Node child2 = fragment.appendChild(document.createText(" text "));
Node child3 = fragment.appendChild(document.createText(" "));
Element child4 = fragment.appendChild(document.createElement("div"));
Element parent = document.createElement("div");
Element oldChild = parent.appendChild(document.createElement("div"));
Element lastChild = parent.appendChild(document.createElement("div"));
oldChild.replaceWith(<Node>[fragment]);
expect(child1.parentNode, equals(parent));
expect(child2.parentNode, equals(parent));
expect(child3.parentNode, equals(parent));