Skip to content

Commit 2a4aa6a

Browse files
committed
-
1 parent e227deb commit 2a4aa6a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/build/patches.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { parse, type Value, type Node } from "kdljs";
1+
import { parse, type Value, type Node, Document } from "kdljs";
22
import type {
33
Enum,
44
Event,
@@ -377,16 +377,16 @@ async function readPatchDocument(fileUrl: URL): Promise<Document> {
377377
* Recursively remove all 'name' fields from the object and its children, and
378378
* replace any empty objects ({} or []) with null.
379379
*/
380-
function sanitizeRemovals(obj: unknown): unknown {
380+
function convertForRemovals(obj: unknown): unknown {
381381
if (Array.isArray(obj)) {
382-
const result = obj.map(sanitizeRemovals).filter((v) => v !== undefined);
382+
const result = obj.map(convertForRemovals).filter((v) => v !== undefined);
383383
return result.length === 0 ? null : result;
384384
}
385385
if (obj && typeof obj === "object") {
386386
const newObj: Record<string, unknown> = {};
387387
for (const [key, value] of Object.entries(obj)) {
388388
if (key !== "name") {
389-
const cleaned = sanitizeRemovals(value);
389+
const cleaned = convertForRemovals(value);
390390
if (cleaned !== undefined) {
391391
newObj[key] = cleaned;
392392
}
@@ -421,11 +421,16 @@ export default async function readPatches(): Promise<{
421421
// Stage 2: Group by patches or removals
422422
const merged = documents.flat();
423423
const patchNodes = merged.filter((node) => node.name !== "removals");
424-
const removalNodes = merged.filter((node) => node.name === "removals").map((node) => node.children)).flat();
424+
const removalNodes = merged
425+
.filter((node) => node.name === "removals")
426+
.map((node) => node.children)
427+
.flat();
425428

426429
// Stage 3: Convert the nodes for patches and removals respectively
427430
const patches = convertKDLNodes(patchNodes);
428-
const removalPatches = sanitizeRemovals(convertKDLNodes(removalNodes));
431+
const removalPatches = convertForRemovals(
432+
convertKDLNodes(removalNodes),
433+
) as DeepPartial<WebIdl>;
429434

430435
// Only because we don't use them
431436
removalPatches.mixins = undefined;

0 commit comments

Comments
 (0)