Skip to content

Commit

Permalink
events: define event handler as enumerable
Browse files Browse the repository at this point in the history
PR-URL: #35931
Backport-PR-URL: #38386
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
benjamingr authored and targos committed Apr 30, 2021
1 parent e51d7c5 commit 6e21e82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,9 @@ function defineEventHandler(emitter, name) {
emitter.addEventListener(name, value);
}
eventHandlerValue = value;
}
},
configurable: true,
enumerable: true
});
}
module.exports = {
Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-eventtarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,10 @@ let asyncTest = Promise.resolve();
}));
target.dispatchEvent(new Event('foo'));
}
{
const target = new EventTarget();
defineEventHandler(target, 'foo');
const descriptor = Object.getOwnPropertyDescriptor(target, 'onfoo');
strictEqual(descriptor.configurable, true);
strictEqual(descriptor.enumerable, true);
}

0 comments on commit 6e21e82

Please sign in to comment.