Skip to content

Commit

Permalink
Fix dispatchCustomEvent to match type definitions in lib.dom.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrozenberg committed Jun 16, 2023
1 parent 74d7eb5 commit de136b8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 0 additions & 6 deletions src/core/dom/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ declare global {
replaceSync: (text: string) => void;
}

interface Event {
// We assign an `Object` at times, though Typescript's dom lib supports
// string or null, so here we allow all three (plus unedfined).
data?: Object | string | null;
}

// Fullscreen proprties
interface Element {
requestFullScreen: any;
Expand Down
6 changes: 2 additions & 4 deletions src/core/dom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,9 @@ export function dispatchCustomEvent(node, name, opt_data, opt_options) {
const data = opt_data || {};
// Constructors of events need to come from the correct window. Sigh.
devAssert(node.ownerDocument);
const event = node.ownerDocument.createEvent('Event');
event.data = data;

const {bubbles, cancelable} = opt_options || DEFAULT_CUSTOM_EVENT_OPTIONS;
event.initEvent(name, bubbles, cancelable);
const event = new MessageEvent(name, {data, bubbles, cancelable});

node.dispatchEvent(event);
}

Expand Down

0 comments on commit de136b8

Please sign in to comment.