mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
LibWeb: Serialize empty media rules with a single newline
This deviates from the CSSOM specification but all modern browsers do this.
This commit is contained in:
parent
a2cccf9420
commit
02a8966b61
Notes:
sideshowbarker
2024-07-17 02:42:21 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/02a8966b61 Pull-request: https://github.com/SerenityOS/serenity/pull/24162
|
@ -1,15 +1,10 @@
|
|||
@media screen {
|
||||
|
||||
}
|
||||
@media screen and ((min-width: 20px) and (max-width: 40px)) {
|
||||
|
||||
}
|
||||
@media screen and (min-resolution: 1dppx) {
|
||||
|
||||
}
|
||||
@media screen and (min-resolution: 2dppx) {
|
||||
|
||||
}
|
||||
@media screen and (min-resolution: 2.54dppx) {
|
||||
|
||||
}
|
||||
|
|
|
@ -54,6 +54,11 @@ String CSSMediaRule::serialized() const
|
|||
builder.append(condition_text());
|
||||
// 3. A single SPACE (U+0020), followed by the string "{", i.e., LEFT CURLY BRACKET (U+007B), followed by a newline.
|
||||
builder.append(" {\n"sv);
|
||||
// AD-HOC: All modern browsers omit the ending newline if there are no CSS rules, so let's do the same.
|
||||
if (css_rules().length() == 0) {
|
||||
builder.append('}');
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
// 4. The result of performing serialize a CSS rule on each rule in the rule’s cssRules list, separated by a newline and indented by two spaces.
|
||||
for (size_t i = 0; i < css_rules().length(); i++) {
|
||||
auto rule = css_rules().item(i);
|
||||
|
|
Loading…
Reference in a new issue