mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +00:00
LibWeb: Make empty media query lists evaluate to true
This commit is contained in:
parent
30377e6e35
commit
16f2f6aa42
Notes:
github-actions[bot]
2024-10-07 13:51:56 +00:00
Author: https://github.com/Gingeh
Commit: 16f2f6aa42
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1611
Reviewed-by: https://github.com/AtkinsSJ ✅
5 changed files with 55 additions and 9 deletions
|
@ -51,10 +51,14 @@ String MediaQueryList::media() const
|
|||
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-matches
|
||||
bool MediaQueryList::matches() const
|
||||
{
|
||||
if (m_media.is_empty())
|
||||
return true;
|
||||
|
||||
for (auto& media : m_media) {
|
||||
if (media->matches())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -64,6 +68,9 @@ bool MediaQueryList::evaluate()
|
|||
if (!window)
|
||||
return false;
|
||||
|
||||
if (m_media.is_empty())
|
||||
return true;
|
||||
|
||||
bool now_matches = false;
|
||||
for (auto& media : m_media) {
|
||||
now_matches = now_matches || media->evaluate(*window);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue