Skip to content

Commit

Permalink
See #931
Browse files Browse the repository at this point in the history
fix: fixed the CSS sanitizer demo hook, thanks @koosvanderkolk
  • Loading branch information
cure53 committed Apr 4, 2024
1 parent bf1f5cf commit 933b9de
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions demos/hooks-sanitize-css-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@
* then add the styles to an array of property-value pairs
*/
function validateStyles(output, styles) {
Object.keys(styles).forEach(prop => {
const value = styles[prop];
if (value && typeof value === 'string') {
const normalizedProp = prop.replace(/([A-Z])/g, '-$1').toLowerCase();
if (allowed_properties.includes(normalizedProp) &&
(allow_css_functions || !/\w+\(/.test(value))) {
output.push(`${normalizedProp}:${value};`);
}
}
});
Object.keys(styles).forEach(function(index) {
if (styles.hasOwnProperty(index)) {
let normalizedKey = styles[index].replace(/([A-Z])/g, '-$1').toLowerCase();
if (allowed_properties.includes(normalizedKey)) {
let value = styles[normalizedKey];
output.push(`${normalizedKey}:${value};`);
}
}
});
}

/**
Expand Down

0 comments on commit 933b9de

Please sign in to comment.