Skip to content

Commit 5eea9df

Browse files
committed
removeTypes cleanup
1 parent c8eda24 commit 5eea9df

File tree

2 files changed

+10
-87
lines changed

2 files changed

+10
-87
lines changed

inputfiles/removedTypes.json

Lines changed: 0 additions & 81 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": {
@@ -197,11 +159,6 @@
197159
}
198160
}
199161
},
200-
"SVGFilterElement": {
201-
"implements": [
202-
"SVGUnitTypes"
203-
]
204-
},
205162
"SVGGradientElement": {
206163
"implements": [
207164
"SVGUnitTypes"
@@ -221,9 +178,6 @@
221178
"SVGPoint": null,
222179
"SVGRect": null,
223180
"SVGSVGElement": {
224-
"implements": [
225-
"SVGUnitTypes"
226-
],
227181
"properties": {
228182
"property": {
229183
"onabort": null,
@@ -233,11 +187,6 @@
233187
}
234188
}
235189
},
236-
"SVGViewElement": {
237-
"implements": [
238-
"SVGUnitTypes"
239-
]
240-
},
241190
"WebKitCSSMatrix": null,
242191
"WebKitDirectoryEntry": null,
243192
"WebKitDirectoryReader": null,
@@ -265,27 +214,11 @@
265214
"GlobalFetch"
266215
]
267216
},
268-
"WheelEvent": {
269-
"properties": {
270-
"property": {
271-
"wheelDelta": null,
272-
"wheelDeltaX": null,
273-
"wheelDeltaY": null
274-
}
275-
}
276-
},
277217
"WorkerGlobalScope": {
278218
"implements": [
279219
"GlobalFetch"
280220
]
281221
},
282-
"XPathEvaluator": {
283-
"methods": {
284-
"method": {
285-
"evaluate": null
286-
}
287-
}
288-
},
289222
"XPathNSResolver": null
290223
}
291224
},
@@ -314,20 +247,6 @@
314247
"portRange": null
315248
}
316249
}
317-
},
318-
"RTCRtpContributingSource": {
319-
"members": {
320-
"member": {
321-
"csrc": null
322-
}
323-
}
324-
},
325-
"MediaTrackConstraintSet": {
326-
"members": {
327-
"member": {
328-
"echoCancelation": null
329-
}
330-
}
331250
}
332251
}
333252
},

src/index.ts

Lines changed: 10 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
}
@@ -211,9 +210,14 @@ function emitDom() {
211210
const name = typeof item === "string" ? item : (item.name || item["new-type"]);
212211
return !template[k].includes(name);
213212
});
213+
if (filtered[k].length === obj[k].length) {
214+
console.warn(`removedTypes.json has a redundant array item in ${JSON.stringify(template[k])}`);
215+
}
214216
}
215217
else if (template[k] !== null) {
216218
filtered[k] = filterByNull(obj[k], template[k]);
219+
} else {
220+
delete filtered[k];
217221
}
218222
}
219223
return filtered;

0 commit comments

Comments
 (0)