Commit e1e71107 authored by Elliott Sprehn's avatar Elliott Sprehn

Add declarataive event handlers.

Now inside the <template> of a SkyElement you can use
on-eventName="method" on any element to add event listeners.

For example you can write <sky-button on-click="handleClick">
and then define handleClick(event) on the element class that
contains the button.

In adding this and tests I also realized that property bindings
were not setup on the initial call to bind(), which is now
fixed in this patch (See change to Node.prototype.bind).

R=eseidel@google.com, rafaelw@chromium.org

Review URL: https://codereview.chromium.org/812713005
parent ea93d43e
......@@ -16,8 +16,9 @@
</style>
<sky-box title='Buttons'>
<sky-button id='button'>Button</sky-button>
<sky-button id='button' on-click='handleClick'>Button</sky-button>
<div>highlight: {{ myButton.highlight }}</div>
<div>clickCount: {{ clickCount }}</div>
</sky-box>
<sky-box title='Checkboxes'>
......@@ -47,6 +48,10 @@ module.exports = class extends SkyElement {
attached() {
this.myButton = this.shadowRoot.getElementById('button');
this.myCheckbox = this.shadowRoot.getElementById('checkbox');
this.clickCount = 0;
}
handleClick(event) {
this.clickCount++;
}
}.register();
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment