Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

fix: on-change event in shadowRoot #122

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions iron-autogrow-textarea.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ interface IronAutogrowTextareaElement extends Polymer.Element, Polymer.IronValid
_constrain(tokens: any): any;
_valueForMirror(): any;
_updateCached(): void;
_onChange(event: any): void;
}

interface HTMLElementTagNameMap {
Expand Down
16 changes: 15 additions & 1 deletion iron-autogrow-textarea.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
disabled$="[[disabled]]"
rows$="[[rows]]"
minlength$="[[minlength]]"
maxlength$="[[maxlength]]"></textarea>
maxlength$="[[maxlength]]"
on-change="_onChange"></textarea>
</div>
</template>
</dom-module>
Expand Down Expand Up @@ -347,5 +348,18 @@
_updateCached: function() {
this.$.mirror.innerHTML = this._constrain(this.tokens);
},

_onChange: function(event) {
// In the Shadow DOM, the `change` event is not leaked into the
// ancestor tree, so we must do this manually.
// See
// https://w3c.github.io/webcomponents/spec/shadow/#events-that-are-not-leaked-into-ancestor-trees.
if (this.shadowRoot) {
this.fire(
event.type,
{sourceEvent: event},
{node: this, bubbles: event.bubbles, cancelable: event.cancelable});
}
},
});
</script>