0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Stop evaluation tests as soon as one returns true

This commit is contained in:
G.Ambatte
2024-07-04 09:32:29 +12:00
parent 2fc5bcabb8
commit b638cca547

View File

@@ -31,9 +31,12 @@ function safeHTML(htmlString) {
// Check remaining elements for blacklisted attributes
if(element.hasAttributes()){
for (const attribute of element.attributes){
let result = false;
blacklistAttrs.forEach((test)=>{result ||= test(attribute);});
if(result) element.removeAttribute(attribute.localName);
for (const test of blacklistAttrs) {
if(test(attribute)){
element.removeAttribute(attribute.localName);
break;
};
};
};
};
});