Skip to content

Commit

Permalink
refac(purify): Rename _isBasicCustomElement
Browse files Browse the repository at this point in the history
  • Loading branch information
ssi02014 committed Aug 10, 2023
1 parent 945fd1d commit e79525c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions dist/purify.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.cjs.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/purify.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.es.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/purify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ function createDOMPurify(window = getGlobal()) {
/* Remove element if anything forbids its presence */
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
/* Check if we have a custom element to handle */
if (!FORBID_TAGS[tagName] && _isBasicCustomElementCheck(tagName)) {
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
if (
CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&
regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)
Expand Down Expand Up @@ -1121,7 +1121,7 @@ function createDOMPurify(window = getGlobal()) {
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
(_isBasicCustomElementCheck(lcTag) &&
(_isBasicCustomElement(lcTag) &&
((CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&
regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag)) ||
(CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&
Expand Down Expand Up @@ -1182,14 +1182,14 @@ function createDOMPurify(window = getGlobal()) {
};

/**
* _isBasicCustomElementCheck
* _isBasicCustomElement
* checks if at least one dash is included in tagName, and it's not the first char
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
*
* @param {string} tagName name of the tag of the node to sanitize
* @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
*/
const _isBasicCustomElementCheck = function (tagName) {
const _isBasicCustomElement = function (tagName) {
return tagName.indexOf('-') > 0;
};

Expand Down

0 comments on commit e79525c

Please sign in to comment.