dompurify 3.4.16 → 3.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/purify.cjs.d.ts +1 -1
- package/dist/purify.cjs.js +272 -196
- package/dist/purify.cjs.js.map +1 -1
- package/dist/purify.es.d.mts +1 -1
- package/dist/purify.es.mjs +272 -196
- package/dist/purify.es.mjs.map +1 -1
- package/dist/purify.js +272 -196
- package/dist/purify.js.map +1 -1
- package/dist/purify.min.js +3 -3
- package/dist/purify.min.js.map +1 -1
- package/package.json +5 -3
- package/src/purify.ts +465 -363
- package/src/utils.ts +36 -0
package/src/utils.ts
CHANGED
|
@@ -46,6 +46,10 @@ const arraySlice = unapply(Array.prototype.slice);
|
|
|
46
46
|
const arraySplice = unapply(Array.prototype.splice);
|
|
47
47
|
const arrayIsArray = Array.isArray;
|
|
48
48
|
|
|
49
|
+
const setCreate = unconstruct(Set) as () => Set<unknown>;
|
|
50
|
+
const setAdd = unapply(Set.prototype.add);
|
|
51
|
+
const setHas = unapply(Set.prototype.has);
|
|
52
|
+
|
|
49
53
|
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
50
54
|
const stringToString = unapply(String.prototype.toString);
|
|
51
55
|
const stringMatch = unapply(String.prototype.match);
|
|
@@ -284,6 +288,34 @@ function lookupGetter<T extends Record<string, any>>(
|
|
|
284
288
|
return fallbackValue;
|
|
285
289
|
}
|
|
286
290
|
|
|
291
|
+
/**
|
|
292
|
+
* Like lookupGetter, but for accessor properties only, and returns null
|
|
293
|
+
* instead of a null-returning fallback when no getter exists on the chain.
|
|
294
|
+
* Lets a caller fall back to a direct property read in environments that
|
|
295
|
+
* lack the getter, where a fallback returning null would be indistinguishable
|
|
296
|
+
* from a legitimate null value (e.g. namespaceURI of a no-namespace element).
|
|
297
|
+
*
|
|
298
|
+
* @param object - The object (usually a prototype) to start the lookup at.
|
|
299
|
+
* @param prop - The accessor property name.
|
|
300
|
+
* @returns The unapplied getter, or null if none was found.
|
|
301
|
+
*/
|
|
302
|
+
function lookupAccessor<T extends Record<string, any>>(
|
|
303
|
+
object: T,
|
|
304
|
+
prop: string
|
|
305
|
+
): ReturnType<typeof unapply<any>> | null {
|
|
306
|
+
while (object !== null) {
|
|
307
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
308
|
+
|
|
309
|
+
if (desc) {
|
|
310
|
+
return desc.get ? unapply(desc.get) : null;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
object = getPrototypeOf(object);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
|
|
287
319
|
function isRegex(value: unknown): value is RegExp {
|
|
288
320
|
try {
|
|
289
321
|
regExpTest(value as RegExp, '');
|
|
@@ -317,6 +349,9 @@ export {
|
|
|
317
349
|
objectToString,
|
|
318
350
|
// RegExp
|
|
319
351
|
regExpTest,
|
|
352
|
+
setAdd,
|
|
353
|
+
setCreate,
|
|
354
|
+
setHas,
|
|
320
355
|
isRegex,
|
|
321
356
|
// String
|
|
322
357
|
stringIndexOf,
|
|
@@ -330,6 +365,7 @@ export {
|
|
|
330
365
|
// Errors
|
|
331
366
|
typeErrorCreate,
|
|
332
367
|
// Other
|
|
368
|
+
lookupAccessor,
|
|
333
369
|
lookupGetter,
|
|
334
370
|
addToSet,
|
|
335
371
|
// Reflect
|