diff --git a/cli/codegen.ts b/cli/codegen.ts index 8a32464..17ccc90 100644 --- a/cli/codegen.ts +++ b/cli/codegen.ts @@ -20,6 +20,14 @@ import type { SourceFile } from "ts-morph"; import { Project } from "ts-morph"; import bcd from "@mdn/browser-compat-data" with { type: "json" }; +/** + * bcdElementEventNames is a list of all element event names in BCD. + */ +export const bcdElementEventNames = Object.keys(bcd.api.Element) + .filter((key) => key.endsWith("_event")) + .map((key) => key.toLowerCase().replace(/_event$/, "")) + .toSorted(); + /** * voidElements is a list of all void elements in HTML. * @see https://developer.mozilla.org/en-US/docs/Glossary/Void_element @@ -105,6 +113,20 @@ if (import.meta.main) { }); } + for (const elementEventName of bcdElementEventNames) { + globalAttrsInterface.addProperty({ + name: `on${elementEventName}`, + hasQuestionToken: true, + type: `string | undefined`, + docs: toDocs({ + description: + `The \`on${elementEventName}\` event handler occurs when the user interacts with the element.`, + see: + `https://developer.mozilla.org/docs/Web/Events/${elementEventName}`, + }), + }); + } + // Create a file for each element. const descriptors = getDescriptors(); for (const descriptor of descriptors) { diff --git a/lib/global_attributes.ts b/lib/global_attributes.ts index 075f4d0..f493aae 100644 --- a/lib/global_attributes.ts +++ b/lib/global_attributes.ts @@ -68,6 +68,371 @@ export interface GlobalAttributes extends DataAttributes { virtualkeyboardpolicy?: string | undefined; /** @see */ writingsuggestions?: string | undefined; + /** + * The `onafterscriptexecute` event handler occurs when the user interacts with the element. + * @see + */ + onafterscriptexecute?: string | undefined; + /** + * The `onanimationcancel` event handler occurs when the user interacts with the element. + * @see + */ + onanimationcancel?: string | undefined; + /** + * The `onanimationend` event handler occurs when the user interacts with the element. + * @see + */ + onanimationend?: string | undefined; + /** + * The `onanimationiteration` event handler occurs when the user interacts with the element. + * @see + */ + onanimationiteration?: string | undefined; + /** + * The `onanimationstart` event handler occurs when the user interacts with the element. + * @see + */ + onanimationstart?: string | undefined; + /** + * The `onauxclick` event handler occurs when the user interacts with the element. + * @see + */ + onauxclick?: string | undefined; + /** + * The `onbeforeinput` event handler occurs when the user interacts with the element. + * @see + */ + onbeforeinput?: string | undefined; + /** + * The `onbeforematch` event handler occurs when the user interacts with the element. + * @see + */ + onbeforematch?: string | undefined; + /** + * The `onbeforescriptexecute` event handler occurs when the user interacts with the element. + * @see + */ + onbeforescriptexecute?: string | undefined; + /** + * The `onbeforexrselect` event handler occurs when the user interacts with the element. + * @see + */ + onbeforexrselect?: string | undefined; + /** + * The `onblur` event handler occurs when the user interacts with the element. + * @see + */ + onblur?: string | undefined; + /** + * The `onclick` event handler occurs when the user interacts with the element. + * @see + */ + onclick?: string | undefined; + /** + * The `oncompositionend` event handler occurs when the user interacts with the element. + * @see + */ + oncompositionend?: string | undefined; + /** + * The `oncompositionstart` event handler occurs when the user interacts with the element. + * @see + */ + oncompositionstart?: string | undefined; + /** + * The `oncompositionupdate` event handler occurs when the user interacts with the element. + * @see + */ + oncompositionupdate?: string | undefined; + /** + * The `oncontentvisibilityautostatechange` event handler occurs when the user interacts with the element. + * @see + */ + oncontentvisibilityautostatechange?: string | undefined; + /** + * The `oncontextmenu` event handler occurs when the user interacts with the element. + * @see + */ + oncontextmenu?: string | undefined; + /** + * The `oncopy` event handler occurs when the user interacts with the element. + * @see + */ + oncopy?: string | undefined; + /** + * The `oncut` event handler occurs when the user interacts with the element. + * @see + */ + oncut?: string | undefined; + /** + * The `ondblclick` event handler occurs when the user interacts with the element. + * @see + */ + ondblclick?: string | undefined; + /** + * The `ondomactivate` event handler occurs when the user interacts with the element. + * @see + */ + ondomactivate?: string | undefined; + /** + * The `ondommousescroll` event handler occurs when the user interacts with the element. + * @see + */ + ondommousescroll?: string | undefined; + /** + * The `onfocus` event handler occurs when the user interacts with the element. + * @see + */ + onfocus?: string | undefined; + /** + * The `onfocusin` event handler occurs when the user interacts with the element. + * @see + */ + onfocusin?: string | undefined; + /** + * The `onfocusout` event handler occurs when the user interacts with the element. + * @see + */ + onfocusout?: string | undefined; + /** + * The `onfullscreenchange` event handler occurs when the user interacts with the element. + * @see + */ + onfullscreenchange?: string | undefined; + /** + * The `onfullscreenerror` event handler occurs when the user interacts with the element. + * @see + */ + onfullscreenerror?: string | undefined; + /** + * The `ongesturechange` event handler occurs when the user interacts with the element. + * @see + */ + ongesturechange?: string | undefined; + /** + * The `ongestureend` event handler occurs when the user interacts with the element. + * @see + */ + ongestureend?: string | undefined; + /** + * The `ongesturestart` event handler occurs when the user interacts with the element. + * @see + */ + ongesturestart?: string | undefined; + /** + * The `ongotpointercapture` event handler occurs when the user interacts with the element. + * @see + */ + ongotpointercapture?: string | undefined; + /** + * The `oninput` event handler occurs when the user interacts with the element. + * @see + */ + oninput?: string | undefined; + /** + * The `onkeydown` event handler occurs when the user interacts with the element. + * @see + */ + onkeydown?: string | undefined; + /** + * The `onkeypress` event handler occurs when the user interacts with the element. + * @see + */ + onkeypress?: string | undefined; + /** + * The `onkeyup` event handler occurs when the user interacts with the element. + * @see + */ + onkeyup?: string | undefined; + /** + * The `onlostpointercapture` event handler occurs when the user interacts with the element. + * @see + */ + onlostpointercapture?: string | undefined; + /** + * The `onmousedown` event handler occurs when the user interacts with the element. + * @see + */ + onmousedown?: string | undefined; + /** + * The `onmouseenter` event handler occurs when the user interacts with the element. + * @see + */ + onmouseenter?: string | undefined; + /** + * The `onmouseleave` event handler occurs when the user interacts with the element. + * @see + */ + onmouseleave?: string | undefined; + /** + * The `onmousemove` event handler occurs when the user interacts with the element. + * @see + */ + onmousemove?: string | undefined; + /** + * The `onmouseout` event handler occurs when the user interacts with the element. + * @see + */ + onmouseout?: string | undefined; + /** + * The `onmouseover` event handler occurs when the user interacts with the element. + * @see + */ + onmouseover?: string | undefined; + /** + * The `onmouseup` event handler occurs when the user interacts with the element. + * @see + */ + onmouseup?: string | undefined; + /** + * The `onmousewheel` event handler occurs when the user interacts with the element. + * @see + */ + onmousewheel?: string | undefined; + /** + * The `onmozmousepixelscroll` event handler occurs when the user interacts with the element. + * @see + */ + onmozmousepixelscroll?: string | undefined; + /** + * The `onpaste` event handler occurs when the user interacts with the element. + * @see + */ + onpaste?: string | undefined; + /** + * The `onpointercancel` event handler occurs when the user interacts with the element. + * @see + */ + onpointercancel?: string | undefined; + /** + * The `onpointerdown` event handler occurs when the user interacts with the element. + * @see + */ + onpointerdown?: string | undefined; + /** + * The `onpointerenter` event handler occurs when the user interacts with the element. + * @see + */ + onpointerenter?: string | undefined; + /** + * The `onpointerleave` event handler occurs when the user interacts with the element. + * @see + */ + onpointerleave?: string | undefined; + /** + * The `onpointermove` event handler occurs when the user interacts with the element. + * @see + */ + onpointermove?: string | undefined; + /** + * The `onpointerout` event handler occurs when the user interacts with the element. + * @see + */ + onpointerout?: string | undefined; + /** + * The `onpointerover` event handler occurs when the user interacts with the element. + * @see + */ + onpointerover?: string | undefined; + /** + * The `onpointerrawupdate` event handler occurs when the user interacts with the element. + * @see + */ + onpointerrawupdate?: string | undefined; + /** + * The `onpointerup` event handler occurs when the user interacts with the element. + * @see + */ + onpointerup?: string | undefined; + /** + * The `onscroll` event handler occurs when the user interacts with the element. + * @see + */ + onscroll?: string | undefined; + /** + * The `onscrollend` event handler occurs when the user interacts with the element. + * @see + */ + onscrollend?: string | undefined; + /** + * The `onscrollsnapchange` event handler occurs when the user interacts with the element. + * @see + */ + onscrollsnapchange?: string | undefined; + /** + * The `onscrollsnapchanging` event handler occurs when the user interacts with the element. + * @see + */ + onscrollsnapchanging?: string | undefined; + /** + * The `onsecuritypolicyviolation` event handler occurs when the user interacts with the element. + * @see + */ + onsecuritypolicyviolation?: string | undefined; + /** + * The `ontouchcancel` event handler occurs when the user interacts with the element. + * @see + */ + ontouchcancel?: string | undefined; + /** + * The `ontouchend` event handler occurs when the user interacts with the element. + * @see + */ + ontouchend?: string | undefined; + /** + * The `ontouchmove` event handler occurs when the user interacts with the element. + * @see + */ + ontouchmove?: string | undefined; + /** + * The `ontouchstart` event handler occurs when the user interacts with the element. + * @see + */ + ontouchstart?: string | undefined; + /** + * The `ontransitioncancel` event handler occurs when the user interacts with the element. + * @see + */ + ontransitioncancel?: string | undefined; + /** + * The `ontransitionend` event handler occurs when the user interacts with the element. + * @see + */ + ontransitionend?: string | undefined; + /** + * The `ontransitionrun` event handler occurs when the user interacts with the element. + * @see + */ + ontransitionrun?: string | undefined; + /** + * The `ontransitionstart` event handler occurs when the user interacts with the element. + * @see + */ + ontransitionstart?: string | undefined; + /** + * The `onwebkitmouseforcechanged` event handler occurs when the user interacts with the element. + * @see + */ + onwebkitmouseforcechanged?: string | undefined; + /** + * The `onwebkitmouseforcedown` event handler occurs when the user interacts with the element. + * @see + */ + onwebkitmouseforcedown?: string | undefined; + /** + * The `onwebkitmouseforceup` event handler occurs when the user interacts with the element. + * @see + */ + onwebkitmouseforceup?: string | undefined; + /** + * The `onwebkitmouseforcewillbegin` event handler occurs when the user interacts with the element. + * @see + */ + onwebkitmouseforcewillbegin?: string | undefined; + /** + * The `onwheel` event handler occurs when the user interacts with the element. + * @see + */ + onwheel?: string | undefined; } /**