Skip to content

Commit 60ecd30

Browse files
authoredOct 28, 2023
Merge pull request #867 from ssi02014/refac/purify
refac: remove and improve unnecessary code
2 parents ce2eaab + ef183e0 commit 60ecd30

9 files changed

+37
-43
lines changed
 

‎dist/purify.cjs.js

+6-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.es.js

+6-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.es.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.js

+6-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/purify.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ const getGlobal = function () {
2828
/**
2929
* Creates a no-op policy for internal use only.
3030
* Don't export this function outside this module!
31-
* @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
31+
* @param {TrustedTypePolicyFactory} trustedTypes The policy factory.
3232
* @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
33-
* @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
33+
* @return {TrustedTypePolicy} The policy created (or null, if Trusted Types
3434
* are not supported or creating the policy failed).
3535
*/
3636
const _createTrustedTypesPolicy = function (trustedTypes, purifyHostElement) {
@@ -412,8 +412,8 @@ function createDOMPurify(window = getGlobal()) {
412412
PARSER_MEDIA_TYPE =
413413
// eslint-disable-next-line unicorn/prefer-includes
414414
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1
415-
? (PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE)
416-
: (PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE);
415+
? DEFAULT_PARSER_MEDIA_TYPE
416+
: cfg.PARSER_MEDIA_TYPE;
417417

418418
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
419419
transformCaseFunc =
@@ -515,7 +515,7 @@ function createDOMPurify(window = getGlobal()) {
515515

516516
/* Parse profile info */
517517
if (USE_PROFILES) {
518-
ALLOWED_TAGS = addToSet({}, [...TAGS.text]);
518+
ALLOWED_TAGS = addToSet({}, TAGS.text);
519519
ALLOWED_ATTR = [];
520520
if (USE_PROFILES.html === true) {
521521
addToSet(ALLOWED_TAGS, TAGS.html);
@@ -658,12 +658,15 @@ function createDOMPurify(window = getGlobal()) {
658658
/* Keep track of all possible SVG and MathML tags
659659
* so that we can perform the namespace checks
660660
* correctly. */
661-
const ALL_SVG_TAGS = addToSet({}, TAGS.svg);
662-
addToSet(ALL_SVG_TAGS, TAGS.svgFilters);
663-
addToSet(ALL_SVG_TAGS, TAGS.svgDisallowed);
664-
665-
const ALL_MATHML_TAGS = addToSet({}, TAGS.mathMl);
666-
addToSet(ALL_MATHML_TAGS, TAGS.mathMlDisallowed);
661+
const ALL_SVG_TAGS = addToSet({}, [
662+
...TAGS.svg,
663+
...TAGS.svgFilters,
664+
...TAGS.svgDisallowed,
665+
]);
666+
const ALL_MATHML_TAGS = addToSet({}, [
667+
...TAGS.mathMl,
668+
...TAGS.mathMlDisallowed,
669+
]);
667670

668671
/**
669672
* @param {Element} element a DOM element whose namespace is being checked

0 commit comments

Comments
 (0)
Please sign in to comment.