Skip to content

A comma-separated media query list is evaluated as a conjunction #230

Description

@lahma

MediaListExtensions.Validate(IMediaList, IRenderDevice) is

public static Boolean Validate(this IMediaList list, IRenderDevice device) => !list.Any(m => !m.Validate(device));

so a media query list matches only when every query in it matches. Media Queries Level 4 §2.1: "A media query list is true if any of its component media queries are true, and false only if all of its component media queries are false." An empty list is true, which the current code also gets right, so the fix is list.Count == 0 || list.Any(m => m.Validate(device)).

Observable in the cascade and, once #228 lands, in matchMedia:

var device = new DefaultRenderDevice { Category = DeviceCategory.Screen };
var list = new CssParser().ParseMedia("screen, print");
list.Validate(device); // false; browsers: true

@media screen, print { } is therefore inactive on a screen device. Found while writing #228; left out of it because the same path decides the cascade.

src/AngleSharp.Css/Extensions/MediaListExtensions.cs. Independent of the other evaluation issues filed alongside.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions