mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-24 01:12:58 -04:00
css: disallow multiple rules in insertRule
This commit is contained in:
@@ -480,6 +480,24 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="CSSStyleSheet_insertRule_multiple_rules">
|
||||
{
|
||||
const style = document.createElement('style');
|
||||
document.head.appendChild(style);
|
||||
const sheet = style.sheet;
|
||||
|
||||
let caught = false;
|
||||
try {
|
||||
sheet.insertRule('a { color: red; } b { color: blue; }');
|
||||
} catch (e) {
|
||||
caught = true;
|
||||
testing.expectEqual('SyntaxError', e.name);
|
||||
}
|
||||
testing.expectTrue(caught);
|
||||
testing.expectEqual(0, sheet.cssRules.length);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="CSSStyleSheet_replaceSync">
|
||||
{
|
||||
const sheet = new CSSStyleSheet();
|
||||
|
||||
@@ -88,6 +88,8 @@ pub fn insertRule(self: *CSSStyleSheet, rule: []const u8, maybe_index: ?u32, pag
|
||||
return error.SyntaxError;
|
||||
};
|
||||
|
||||
if (it.next() != null) return error.SyntaxError;
|
||||
|
||||
const style_rule = try CSSStyleRule.init(page);
|
||||
try style_rule.setSelectorText(parsed_rule.selector, page);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user