Skip to content

Commit 13833d4

Browse files
authored
handle object type listeners
1 parent a404473 commit 13833d4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

code-input.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,13 @@ var codeInput = {
865865
addEventListener(type, listener, options = undefined) {
866866
// Save a copy of the callback where `this` refers to the code-input element.
867867
// This callback is modified to only run when the handleEventsFromTextarea is set.
868-
let boundCallback = function(evt) { listener(evt); }.bind(this);
868+
let boundCallback = function (evt) {
869+
if (typeof listener === 'function') {
870+
listener(evt);
871+
} else if (listener && listener.handleEvent) {
872+
listener.handleEvent(evt);
873+
}
874+
}.bind(this);
869875
this.boundEventCallbacks[listener] = boundCallback;
870876

871877
if (codeInput.textareaSyncEvents.includes(type)) {
@@ -1041,4 +1047,4 @@ var codeInput = {
10411047
}
10421048
}
10431049

1044-
customElements.define("code-input", codeInput.CodeInput);
1050+
customElements.define("code-input", codeInput.CodeInput);

0 commit comments

Comments
 (0)