diff options
author | XhmikosR <xhmikosr@gmail.com> | 2021-08-10 18:07:39 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2021-10-05 19:52:11 +0300 |
commit | 2b4d0d166b58cabfb0384a2081d84e51df84e37f (patch) | |
tree | 2798ad58c1131e68e7943b737efce006b86d1794 /js/src/util | |
parent | 9f1579aa048eb6a7dee30f60e5c2357b049eff3a (diff) |
Enable `unicorn/no-for-loop` rule
Diffstat (limited to 'js/src/util')
-rw-r--r-- | js/src/util/sanitizer.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js index 2a0597be79..c02a4eb906 100644 --- a/js/src/util/sanitizer.js +++ b/js/src/util/sanitizer.js @@ -46,8 +46,8 @@ const allowedAttribute = (attribute, allowedAttributeList) => { const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp) // Check if a regular expression validates the attribute. - for (let i = 0, len = regExp.length; i < len; i++) { - if (regExp[i].test(attributeName)) { + for (const element of regExp) { + if (element.test(attributeName)) { return true } } @@ -102,8 +102,7 @@ export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html') const elements = [].concat(...createdDocument.body.querySelectorAll('*')) - for (let i = 0, len = elements.length; i < len; i++) { - const element = elements[i] + for (const element of elements) { const elementName = element.nodeName.toLowerCase() if (!Object.keys(allowList).includes(elementName)) { |