LadybirdBrowser / ladybird

Truly independent web browser
https://ladybird.org
BSD 2-Clause "Simplified" License
20.25k stars 833 forks source link

LibWeb: Styles inside `@media` are ignored if there is no query #1551

Open aplefull opened 6 days ago

aplefull commented 6 days ago

I'm not sure if @media without actual query is valid but Chrome and Firefox seem to apply styles anyway. This reduction also comes from a real website iirc, so things like that exist in the wild.

Example:

<style>
    @media {
        body {
            background-color: crimson;
        }
    }
</style>
Chrome/Firefox Ladybird
![image](https://github.com/user-attachments/assets/b0bec4bc-f72b-49d5-8d6f-2fc33ed452f3) ![image](https://github.com/user-attachments/assets/9528dd49-e07c-45d3-81b5-4909af93853c)
AtkinsSJ commented 6 days ago

Thanks! Spec says that it is indeed valid, so this is a bug in our implementation:

An empty media query list evaluates to true. For example, these are equivalent:

@media all { … } @media { … } https://www.w3.org/TR/mediaqueries-5/#mq-list