Skip to content

Commit 1037c4c

Browse files
committed
removeTypes cleanup
1 parent c8eda24 commit 1037c4c

File tree

2 files changed

+7
-74
lines changed

2 files changed

+7
-74
lines changed

inputfiles/removedTypes.json

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,6 @@
8787
}
8888
}
8989
},
90-
"Document": {
91-
"methods": {
92-
"method": {
93-
"evaluate": null
94-
}
95-
}
96-
},
9790
"FederatedCredential": null,
9891
"HTMLAreasCollection": null,
9992
"HTMLBodyElement": {
@@ -108,27 +101,6 @@
108101
}
109102
}
110103
},
111-
"HTMLElement": {
112-
"methods": {
113-
"method": {
114-
"scrollIntoView": null,
115-
"insertAdjacentElement": null,
116-
"insertAdjacentHTML": null,
117-
"insertAdjacentText": null
118-
}
119-
}
120-
},
121-
"HTMLHRElement": {
122-
"implements": null
123-
},
124-
"HTMLIFrameElement": {
125-
"properties": {
126-
"property": {
127-
"onload": null
128-
}
129-
}
130-
},
131-
"MediaQueryListListener": null,
132104
"MessageEvent": {
133105
"methods": {
134106
"method": {
@@ -139,18 +111,8 @@
139111
"MSCredentials": null,
140112
"MSDCCEvent": null,
141113
"MSDSHEvent": null,
142-
"MSPortRange": null,
143114
"MSStreamReader": null,
144-
"OverconstrainedErrorEvent": null,
145115
"PasswordCredential": null,
146-
"Screen": {
147-
"methods": {
148-
"method": {
149-
"msLockOrientation": null,
150-
"msUnlockOrientation": null
151-
}
152-
}
153-
},
154116
"StorageEvent": {
155117
"methods": {
156118
"method": {
@@ -265,27 +227,11 @@
265227
"GlobalFetch"
266228
]
267229
},
268-
"WheelEvent": {
269-
"properties": {
270-
"property": {
271-
"wheelDelta": null,
272-
"wheelDeltaX": null,
273-
"wheelDeltaY": null
274-
}
275-
}
276-
},
277230
"WorkerGlobalScope": {
278231
"implements": [
279232
"GlobalFetch"
280233
]
281234
},
282-
"XPathEvaluator": {
283-
"methods": {
284-
"method": {
285-
"evaluate": null
286-
}
287-
}
288-
},
289235
"XPathNSResolver": null
290236
}
291237
},
@@ -314,20 +260,6 @@
314260
"portRange": null
315261
}
316262
}
317-
},
318-
"RTCRtpContributingSource": {
319-
"members": {
320-
"member": {
321-
"csrc": null
322-
}
323-
}
324-
},
325-
"MediaTrackConstraintSet": {
326-
"members": {
327-
"member": {
328-
"echoCancelation": null
329-
}
330-
}
331263
}
332264
}
333265
},

src/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,11 @@ function emitDom() {
197197

198198
function filterByNull(obj: any, template: any) {
199199
if (!template) return obj;
200-
const filtered: any = {};
201-
for (const k in obj) {
202-
if (!template.hasOwnProperty(k)) {
203-
filtered[k] = obj[k];
204-
}
205-
else if (Array.isArray(template[k])) {
200+
const filtered = { ...obj };
201+
for (const k in template) {
202+
if (!obj[k]) {
203+
console.warn(`removedTypes.json has a redundant field ${k} in ${JSON.stringify(template)}`);
204+
} else if (Array.isArray(template[k])) {
206205
if (!Array.isArray(obj[k])) {
207206
throw new Error(`Removal template ${k} is an array but the original field is not`);
208207
}
@@ -214,6 +213,8 @@ function emitDom() {
214213
}
215214
else if (template[k] !== null) {
216215
filtered[k] = filterByNull(obj[k], template[k]);
216+
} else {
217+
delete filtered[k];
217218
}
218219
}
219220
return filtered;

0 commit comments

Comments
 (0)