From 2b4d0d166b58cabfb0384a2081d84e51df84e37f Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 10 Aug 2021 18:07:39 +0300 Subject: Enable `unicorn/no-for-loop` rule --- js/src/util/sanitizer.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'js/src/util') 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)) { -- cgit v1.2.3