From 119ebd99ab182b7c8c8967ea2956a1e2c572d58a Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 27 Jan 2022 14:18:30 +0100 Subject: [PATCH] Update clean attr --- src/parser/model/ParserHtml.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/parser/model/ParserHtml.js b/src/parser/model/ParserHtml.js index cbdb3d4bb..5ce063332 100644 --- a/src/parser/model/ParserHtml.js +++ b/src/parser/model/ParserHtml.js @@ -1,4 +1,4 @@ -import { each, isString, isFunction, isUndefined, forEach } from 'underscore'; +import { each, isString, isFunction, isUndefined } from 'underscore'; import BrowserParserHtml from './BrowserParserHtml'; export default config => { @@ -328,11 +328,13 @@ export default config => { __clearUnsafeAttr(node) { const attrs = node.attributes || []; const nodes = node.childNodes || []; - forEach(attrs, attr => { + const toRemove = []; + each(attrs, attr => { const name = attr.nodeName || ''; - name.indexOf('on') === 0 && node.removeAttribute(name); + name.indexOf('on') === 0 && toRemove.push(name); }); - forEach(nodes, node => this.__clearUnsafeAttr(node)); + toRemove.map(name => node.removeAttribute(name)); + each(nodes, node => this.__clearUnsafeAttr(node)); }, }; };