Make element.style["color"] work in Sky
This CL makes CSSStyleDeclaration a bit less painful to use by replacing the crazy Java-style APIs with overloading operator[] and operator[]=. R=esprehn@chromium.org, ojan@chromium.org Review URL: https://codereview.chromium.org/942553002
This commit is contained in:
parent
0d5dc91906
commit
cd6b52b4a3
@ -47,12 +47,12 @@ void main() {
|
||||
});
|
||||
|
||||
test("should hit test child with layered parent", () {
|
||||
document.querySelector('parent').style.setProperty("transform", "translate3d(0, 0, 0)");
|
||||
document.querySelector('parent').style["transform"] = "translate3d(0, 0, 0)";
|
||||
hitTestWithChildren();
|
||||
});
|
||||
|
||||
test("should hit test transformed child", () {
|
||||
document.querySelector('child').style.setProperty("transform", "translate3d(100px, 0, 0)");
|
||||
document.querySelector('child').style["transform"] = "translate3d(100px, 0, 0)";
|
||||
expect(document.elementFromPoint(50, 210).tagName, equals('parent'));
|
||||
expect(document.elementFromPoint(150, 210).tagName, equals('child'));
|
||||
});
|
||||
|
@ -19,7 +19,7 @@ void main() {
|
||||
var target = document.querySelector('div');
|
||||
|
||||
target.classList.add("wide");
|
||||
expect(window.getComputedStyle(target).getPropertyValue("width"),
|
||||
expect(window.getComputedStyle(target)["width"],
|
||||
equals("200px"));
|
||||
});
|
||||
|
||||
@ -27,7 +27,7 @@ void main() {
|
||||
var target = document.querySelectorAll('div')[1];
|
||||
|
||||
target.setAttribute("id", "high");
|
||||
expect(window.getComputedStyle(target).getPropertyValue("height"),
|
||||
expect(window.getComputedStyle(target)["height"],
|
||||
equals("200px"));
|
||||
});
|
||||
}
|
||||
|
@ -102,23 +102,23 @@ main() {
|
||||
});
|
||||
|
||||
test("should dynamically update style", () {
|
||||
expect(window.getComputedStyle(target).getPropertyValue("font-size"),
|
||||
expect(window.getComputedStyle(target)["font-size"],
|
||||
equals("5px"));
|
||||
target.classList.add("font-10");
|
||||
target.classList.add("font-12");
|
||||
expect(window.getComputedStyle(target).getPropertyValue("font-size"),
|
||||
expect(window.getComputedStyle(target)["font-size"],
|
||||
equals("12px"));
|
||||
target.classList.add("font-24");
|
||||
expect(window.getComputedStyle(target).getPropertyValue("font-size"),
|
||||
expect(window.getComputedStyle(target)["font-size"],
|
||||
equals("24px"));
|
||||
target.classList.remove("font-12");
|
||||
expect(window.getComputedStyle(target).getPropertyValue("font-size"),
|
||||
expect(window.getComputedStyle(target)["font-size"],
|
||||
equals("24px"));
|
||||
target.classList.remove("font-24");
|
||||
expect(window.getComputedStyle(target).getPropertyValue("font-size"),
|
||||
expect(window.getComputedStyle(target)["font-size"],
|
||||
equals("10px"));
|
||||
target.classList.remove("font-10");
|
||||
expect(window.getComputedStyle(target).getPropertyValue("font-size"),
|
||||
expect(window.getComputedStyle(target)["font-size"],
|
||||
equals("5px"));
|
||||
});
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
var log = document.getElementById("log");
|
||||
var i = 1;
|
||||
for (Element element = tests.firstElementChild; element != null; element = element.nextElementSibling) {
|
||||
var order = int.parse(window.getComputedStyle(element).getPropertyValue("order"));
|
||||
var order = int.parse(window.getComputedStyle(element)["order"]);
|
||||
var div = document.createElement("div");
|
||||
var text = (order == i) ? "PASS" : "FAIL";
|
||||
text += ": <"
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
test('should not exist', () {
|
||||
var sandbox = document.getElementById("sandbox");
|
||||
expect(window.getComputedStyle(sandbox).getPropertyValue("color"),
|
||||
expect(window.getComputedStyle(sandbox)["color"],
|
||||
equals("rgb(0, 0, 255)"));
|
||||
});
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ void main() {
|
||||
test('should render', () {
|
||||
var foo = document.querySelector('foo');
|
||||
foo.setAttribute('style', 'border: 1px solid red');
|
||||
expect(foo.style.getPropertyValue("border"), equals('1px solid rgb(255, 0, 0)'));
|
||||
expect(foo.style["border"], equals('1px solid rgb(255, 0, 0)'));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
@ -15,9 +15,8 @@ void main() {
|
||||
|
||||
|
||||
expect(foo.getAttribute('style'), equals('color: red'));
|
||||
expect(foo.style.getPropertyValue("color"), equals('rgb(255, 0, 0)'));
|
||||
expect(window.getComputedStyle(foo).getPropertyValue("color"),
|
||||
equals('rgb(255, 0, 0)'));
|
||||
expect(foo.style["color"], equals('rgb(255, 0, 0)'));
|
||||
expect(window.getComputedStyle(foo)["color"], equals('rgb(255, 0, 0)'));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
@ -22,14 +22,12 @@ void main() {
|
||||
|
||||
test('should allow sheets to apply when they match', () {
|
||||
var element = document.getElementById('matches');
|
||||
expect(window.getComputedStyle(element).getPropertyValue("color"),
|
||||
equals("rgb(255, 0, 0)"));
|
||||
expect(window.getComputedStyle(element)["color"], equals("rgb(255, 0, 0)"));
|
||||
});
|
||||
|
||||
test('should cause sheets to be skipped when they do not match', () {
|
||||
var element = document.getElementById('does-not-match');
|
||||
expect(window.getComputedStyle(element).getPropertyValue("color"),
|
||||
"rgb(0, 0, 0)");
|
||||
expect(window.getComputedStyle(element)["color"], equals("rgb(0, 0, 0)"));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user