diff --git a/iron-autogrow-textarea.d.ts b/iron-autogrow-textarea.d.ts index 97b63b5..a0e38a4 100644 --- a/iron-autogrow-textarea.d.ts +++ b/iron-autogrow-textarea.d.ts @@ -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 { diff --git a/iron-autogrow-textarea.html b/iron-autogrow-textarea.html index 71a7f09..9a94950 100644 --- a/iron-autogrow-textarea.html +++ b/iron-autogrow-textarea.html @@ -112,7 +112,8 @@ disabled$="[[disabled]]" rows$="[[rows]]" minlength$="[[minlength]]" - maxlength$="[[maxlength]]"> + maxlength$="[[maxlength]]" + on-change="_onChange"> @@ -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}); + } + }, });