Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: be9952291541540d2738c1b1d608a85810916163
https://github.com/WebKit/WebKit/commit/be9952291541540d2738c1b1d608a85810916163
Author: Chris Dumez <[email protected]>
Date: 2026-06-22 (Mon, 22 Jun 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/cssom/medialist-appendmedium-parse-single-and-dedup-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/cssom/medialist-appendmedium-parse-single-and-dedup.html
M Source/WebCore/css/MediaList.cpp
Log Message:
-----------
MediaList.appendMedium() should parse as a single media query and suppress
duplicates
https://bugs.webkit.org/show_bug.cgi?id=317559
Reviewed by Anne van Kesteren.
MediaList::appendMedium() did not follow the CSSOM algorithm
(https://drafts.csswg.org/cssom/#dom-medialist-appendmedium). It parsed
its argument with the comma-separated media query *list* parser and
unconditionally appended every resulting query, with no duplicate check.
Per the spec, the value must be parsed as a single media query: parsing is
a no-op if it yields anything other than exactly one query, and the query
must not be appended if it is already present in the list. As a result:
- appendMedium("screen, print") appended two queries instead of being a
no-op.
- appendMedium("screen") called twice produced "screen, screen" instead of
deduplicating to "screen".
Fix appendMedium() to bail out unless parsing produces exactly one media
query, and to skip appending a query whose serialization already matches an
existing entry. This aligns our behavior with Blink, whose
MediaQuerySet::CopyAndAdd() rejects results whose size != 1 and skips
queries already in the list.
Test:
imported/w3c/web-platform-tests/css/cssom/medialist-appendmedium-parse-single-and-dedup.html
*
LayoutTests/imported/w3c/web-platform-tests/css/cssom/medialist-appendmedium-parse-single-and-dedup-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/cssom/medialist-appendmedium-parse-single-and-dedup.html:
Added.
* Source/WebCore/css/MediaList.cpp:
(WebCore::MediaList::appendMedium):
Canonical link: https://commits.webkit.org/315594@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications