fix overflowing and chained selectors

This commit is contained in:
Ewan Howell 2024-04-10 13:25:54 +01:00
parent a4289e4af9
commit 669bbd5e83
2 changed files with 11 additions and 4 deletions

View File

@ -804,6 +804,7 @@
background-color: var(--color-frame);
border: 2px solid var(--color-frame);
border-top: none;
overflow: hidden;
}
.custom_thumbnail_preview {
position: relative;

View File

@ -442,15 +442,21 @@ const CustomTheme = {
style.textContent = theme.thumbnail;
const sheet = style.sheet;
for (const rule of sheet.cssRules) {
thumbnailStyles += `.custom_theme_thumbnail_${theme.id} ${rule.selectorText} { ${rule.style.cssText} }\n`;
}
const selectors = rule.selectorText.split(/(?<!\[[^\]]*),(?![^\[]*\])|(?<!"[^"]*),(?![^"]*")/g).map(e => e.trim())
for (const selector of selectors) {
thumbnailStyles += `.custom_theme_thumbnail_${theme.id} ${selector} { ${rule.style.cssText} }\n`;
}
}
}
if (CustomTheme.data.customized) {
style.textContent = CustomTheme.data.thumbnail;
const sheet = style.sheet;
for (const rule of sheet.cssRules) {
thumbnailStyles += `.custom_theme_thumbnail_${CustomTheme.data.id} ${rule.selectorText} { ${rule.style.cssText} }\n`;
}
const selectors = rule.selectorText.split(/(?<!\[[^\]]*),(?![^\[]*\])|(?<!"[^"]*),(?![^"]*")/g).map(e => e.trim())
for (const selector of selectors) {
thumbnailStyles += `.custom_theme_thumbnail_${CustomTheme.data.id} ${selector} { ${rule.style.cssText} }\n`;
}
}
}
document.head.removeChild(style);
$('style#theme_thumbnail_css').text(thumbnailStyles);