Custom elements should have class side inheritance.

We were not setting the __proto__ property of the generated constructor
so the generated class didn't inherit from the passed class which meant
that statics were not available.

This patch adds the missing call to setPrototype (which sets __proto__).

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/814683002
This commit is contained in:
Elliott Sprehn 2014-12-17 14:24:34 -08:00
parent 90bd22adc9
commit b486b63a64
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,5 @@
Running 1 tests
ok 1 Custom element constructor should inherit from the passed constructor
1 tests
1 pass
0 fail

View File

@ -0,0 +1,18 @@
<html>
<import src="../resources/mocha.sky" />
<import src="../resources/chai.sky" />
<script>
describe("Custom element constructor", function() {
it("should inherit from the passed constructor", function() {
class TestElementClass {
static test() { return 10; }
}
var TestElement = document.registerElement("test-element-1", {
prototype: TestElementClass.prototype,
});
assert.isFunction(TestElement.test);
assert.equal(TestElement.test(), 10);
});
});
</script>
</html>