Add support for Element#getAttributes

As described in //sky/specs/apis.md

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/691893002
This commit is contained in:
Adam Barth
2014-10-30 13:55:59 -07:00
parent 681ec14ced
commit dc0521fb43
2 changed files with 17 additions and 6 deletions

View File

@@ -1,9 +1,10 @@
Running 5 tests
Running 6 tests
ok 1 Attribute collection should get by index
ok 2 Attribute collection should get by name
ok 3 Attribute collection should set by name
ok 4 Attribute collection should be case sensitive
ok 5 Attribute collection should live update
5 tests
5 pass
ok 3 Attribute collection should get all at once
ok 4 Attribute collection should set by name
ok 5 Attribute collection should be case sensitive
ok 6 Attribute collection should live update
6 tests
6 pass
0 fail

View File

@@ -24,6 +24,16 @@ describe("Attribute collection", function() {
assert.equal(div.attributes.attr0.value, "value0");
assert.equal(div.attributes.attr1.value, "value1");
});
it("should get all at once", function() {
div.setAttribute("attr0", "value0");
div.setAttribute("attr1", "value1");
var attrs = div.getAttributes();
assert.equal(attrs.length, 2);
assert.equal(attrs[0].name, "attr0");
assert.equal(attrs[0].value, "value0");
assert.equal(attrs[1].name, "attr1");
assert.equal(attrs[1].value, "value1");
});
it("should set by name", function() {
div.setAttribute("attrName", "value0");
div.attributes.attrName.value = "new value";