Skip to content

Commit

Permalink
Deoptimize custom event detail (#5123)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Sep 6, 2023
1 parent c6aa575 commit 884e678
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/ast/nodes/shared/knownGlobals.ts
Expand Up @@ -478,7 +478,17 @@ const knownGlobals: GlobalDescription = {
CSSSupportsRule: C,
CustomElementRegistry: C,
customElements: O,
CustomEvent: C,
CustomEvent: {
__proto__: null,
[ValueProperties]: {
deoptimizeArgumentsOnCall({ args }: NodeInteractionCalled) {
args[2]?.deoptimizePath(['detail']);
},
getLiteralValue: getTruthyLiteralValue,
hasEffectsWhenCalled: returnFalse
},
prototype: O
},
DataTransfer: C,
DataTransferItem: C,
DataTransferItemList: C,
Expand Down
3 changes: 3 additions & 0 deletions test/form/samples/custom-event-detail/_config.js
@@ -0,0 +1,3 @@
module.exports = defineTest({
description: 'observes side effects for custom event payloads'
});
5 changes: 5 additions & 0 deletions test/form/samples/custom-event-detail/_expected.js
@@ -0,0 +1,5 @@
const detail = { value: null };
const event = new CustomEvent('test', { detail });
event.detail.value = true;
if (detail.value) console.log('ok');
else console.log('failed');
5 changes: 5 additions & 0 deletions test/form/samples/custom-event-detail/main.js
@@ -0,0 +1,5 @@
const detail = { value: null };
const event = new CustomEvent('test', { detail });
event.detail.value = true;
if (detail.value) console.log('ok');
else console.log('failed');

0 comments on commit 884e678

Please sign in to comment.