Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: fe205bdb796c4b09d211a2c8df1fca578c4674da
https://github.com/WebKit/WebKit/commit/fe205bdb796c4b09d211a2c8df1fca578c4674da
Author: Chris Dumez <[email protected]>
Date: 2026-06-21 (Sun, 21 Jun 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/cssom/medialist-deletemedium-parse-and-remove-all-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/cssom/medialist-deletemedium-parse-and-remove-all.html
M Source/WebCore/css/MediaList.cpp
Log Message:
-----------
MediaList.deleteMedium() should parse its argument and remove all matching
queries
https://bugs.webkit.org/show_bug.cgi?id=317560
Reviewed by Anne van Kesteren.
MediaList::deleteMedium() did not follow the CSSOM algorithm
(https://drafts.csswg.org/cssom/#dom-medialist-deletemedium). It compared
the caller's raw, un-normalized argument string against each query's
*serialized* form using a case-insensitive string comparison, and removed
only the first match. As a result:
- deleteMedium("screen and (min-width:480px)") threw a NotFoundError against
a stored "screen and (min-width: 480px)", because serialization inserts a
space after the colon and the raw input does not, so the strings differed.
- When the list contained more than one equal query, only the first was
removed.
Per the spec, the argument must be parsed as a single media query, and every
query in the list that compares equal to it must be removed, throwing a
NotFoundError only when nothing matched. Fix deleteMedium() to parse the
argument and compare canonical serializations, removing all matching queries
via Vector::removeAllMatching(). An argument that does not parse to exactly
one media query results in a NotFoundError, as the spec requires.
This aligns our behavior with both Blink (MediaQuerySet::CopyAndRemove) and
Gecko (MediaList::delete_medium), which likewise parse the argument and
remove every structurally-equal query.
Test:
imported/w3c/web-platform-tests/css/cssom/medialist-deletemedium-parse-and-remove-all.html
*
LayoutTests/imported/w3c/web-platform-tests/css/cssom/medialist-deletemedium-parse-and-remove-all-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/cssom/medialist-deletemedium-parse-and-remove-all.html:
Added.
* Source/WebCore/css/MediaList.cpp:
(WebCore::MediaList::deleteMedium):
Canonical link: https://commits.webkit.org/315579@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications