Improved handling of secure message <style> CSS class names

This commit is contained in:
the-djmaze 2023-02-14 15:21:43 +01:00
parent 64818025e8
commit 5105f6d4c1
3 changed files with 22 additions and 19 deletions

View file

@ -27,11 +27,13 @@ export class CSS
* Given css array, parses it and then for every selector,
* prepends namespace to prevent css collision issues
*/
css.applyNamespace = (namespace) => css.forEach(obj => {
css.applyNamespace = (namespace, prefix) => css.forEach(obj => {
if (obj.type === 'media') {
obj.subStyles.applyNamespace(namespace);
obj.subStyles.applyNamespace(namespace, prefix);
} else {
obj.selector = obj.selector.split(',').map(selector => namespace + ' ' + selector).join(',');
obj.selector = obj.selector.split(',').map(selector =>
namespace + ' ' + selector.replace('.', '.'+prefix)
).join(',');
}
});