Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions inputfiles/addedTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,6 @@
}
}
},
"HTMLTableDataCellElement": {
"name": "HTMLTableDataCellElement",
"extends": "HTMLTableCellElement",
"noInterfaceObject": true,
"deprecated": "prefer HTMLTableCellElement",
"exposed": "Window"
},
"HTMLTableHeaderCellElement": {
"name": "HTMLTableHeaderCellElement",
"extends": "HTMLTableCellElement",
"noInterfaceObject": true,
"deprecated": "prefer HTMLTableCellElement",
"exposed": "Window"
},
"HTMLDocument": {
"name": "HTMLDocument",
"extends": "Document",
"exposed": "Window"
},
"HTMLMediaElement": {
"events": {
"event": [
Expand Down
4 changes: 4 additions & 0 deletions inputfiles/patches/html.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ enum ImageOrientation {
// See https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1507#issuecomment-1454792451
none
}

interface HTMLTableDataCellElement extends=HTMLTableCellElement exposed=Window deprecated="prefer HTMLTableCellElement" noInterfaceObject
interface HTMLTableHeaderCellElement extends=HTMLTableCellElement exposed=Window deprecated="prefer HTMLTableCellElement" noInterfaceObject
interface HTMLDocument extends=Document exposed=Window
27 changes: 24 additions & 3 deletions src/build/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function parseKDL(kdlText: string): DeepPartial<WebIdl> {
const nodes = output!;
const enums: Record<string, Enum> = {};
const mixin: Record<string, DeepPartial<Interface>> = {};
const interfaces: Record<string, DeepPartial<Interface>> = {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to name it interfaces because interface is a reserved word


for (const node of nodes) {
const name = string(node.values[0]);
Expand All @@ -76,14 +77,21 @@ function parseKDL(kdlText: string): DeepPartial<WebIdl> {
enums[name] = handleEnum(node);
break;
case "interface-mixin":
mixin[name] = handleMixin(node);
mixin[name] = handleMixinandInterfaces(node, "mixin");
break;
case "interface":
interfaces[name] = handleMixinandInterfaces(node, "interface");
break;
default:
throw new Error(`Unknown node name: ${node.name}`);
}
}

return { enums: { enum: enums }, mixins: { mixin } };
return {
enums: { enum: enums },
mixins: { mixin },
interfaces: { interface: interfaces },
};
}

/**
Expand Down Expand Up @@ -118,7 +126,10 @@ function handleEnum(node: Node): Enum {
* @param node The mixin node to handle.
* @param mixins The record of mixins to update.
*/
function handleMixin(node: Node): DeepPartial<Interface> {
function handleMixinandInterfaces(
node: Node,
type: "mixin" | "interface",
): DeepPartial<Interface> {
const name = node.values[0];

const event: Event[] = [];
Expand All @@ -145,12 +156,22 @@ function handleMixin(node: Node): DeepPartial<Interface> {
}
}

const interfaceObject = type === "interface" && {
...optionalMember("exposed", "string", node.properties?.exposed),
...optionalMember("deprecated", "string", node.properties?.deprecated),
...optionalMember(
"noInterfaceObject",
"boolean",
node.properties?.noInterfaceObject,
),
};
return {
name,
events: { event },
properties: { property },
methods: { method },
...optionalMember("extends", "string", node.properties?.extends),
...interfaceObject,
} as DeepPartial<Interface>;
}

Expand Down
Loading