Skip to content

[css-conditional-5] Add matchContainer() and ContainerQueryList API text#13551

Open
meyerweb wants to merge 11 commits intow3c:mainfrom
meyerweb:master
Open

[css-conditional-5] Add matchContainer() and ContainerQueryList API text#13551
meyerweb wants to merge 11 commits intow3c:mainfrom
meyerweb:master

Conversation

@meyerweb
Copy link
Copy Markdown
Member

As per #6205.

@meyerweb meyerweb changed the title [css-spec-shortname-1] Add matchContainer() and ContainerQueryList API text [css-conditional-5] Add matchContainer() and ContainerQueryList API text Feb 23, 2026
Comment thread css-conditional-5/Overview.bs Outdated
Comment thread css-conditional-5/Overview.bs Outdated

<ol>

<li>If <var>target</var>'s <a>matches state</a> has changed since the last time these steps were run,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about describe or mention what the target is? I initially thought it was element itself. But the recent issues talks and container query behavior is finding eligible ancestor of the element.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

@DevSDK DevSDK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I focused on referring to the element's target container which is already defined as a "query container" for @container.

Comment thread css-conditional-5/Overview.bs Outdated

A {{ContainerQueryList}} object has an associated
<dfn for=ContainerQueryList>container</dfn> which is the
<a lt='serialize a container query list'>serialized</a>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we missed the serialization rule here.

We may need to create/adopt the existing rule? https://drafts.csswg.org/cssom-1/#serialize-a-media-query-list

Comment thread css-conditional-5/Overview.bs Outdated
Comment thread css-conditional-5/Overview.bs Outdated

<li>If <var>target</var>'s <a>matches state</a> has changed since the last time these steps were run,
<a>fire an event</a> named <a event>change</a> at <var>target</var>
using {{ContainerQueryListEvent}},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we missed definition ContainerQueryListEvent idl here?

FYR: https://drafts.csswg.org/cssom-view/#mediaquerylistevent

and also We may need to ContainerQueryListEventInit that correspond with MediaQueryListEventInit

Comment thread css-conditional-5/Overview.bs
Comment thread css-conditional-5/Overview.bs

<ol>

<li>If <var>target</var>'s <a>matches state</a> has changed since the last time these steps were run,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meyerweb and others added 5 commits March 20, 2026 09:46
Co-authored-by: Seokho Song <0xdevssh@gmail.com>
Co-authored-by: Seokho Song <0xdevssh@gmail.com>
Co-authored-by: Seokho Song <0xdevssh@gmail.com>
Co-authored-by: Seokho Song <0xdevssh@gmail.com>
Co-authored-by: Seokho Song <0xdevssh@gmail.com>
@DevSDK
Copy link
Copy Markdown

DevSDK commented Mar 30, 2026

cc + @frivoal can you take a look here? :)

@DevSDK
Copy link
Copy Markdown

DevSDK commented Apr 13, 2026

While I'm working on the CL, there are three things need to be consider:

  1. -List name: Media queries can be a list with a ',' separator, but container queries don't seem to have a similar syntax.
  2. The query itself: Should we accept a container name or not? If we do, what would be a good approach? matchContainer("container name and condition") or matchContainer("condition", containerName)?
  3. Serialization rules (maybe adopt containerRule.containerQuery?)

@DevSDK
Copy link
Copy Markdown

DevSDK commented Apr 20, 2026

Additionally, @andruud mentioned that we should specify the event timing in the CL.

Since the following specs are managed by HTML's event loop-processing-model:

  • resize-observer Algorithms:

    Note: The following algorithms are invoked as a part of update the rendering in the html spec: gather active resize observations at depth, has active resize observations, has skipped resize observations, broadcast active resize observations and deliver resize loop error notification.

  • css-conditional-5 Updating Scroll State:

    To avoid such layout cycles, scroll-state query containers update their current state as part of run snapshot post-layout state steps which is only run at specific points in the HTML event loop processing model.
    When asked to run snapshot post-layout state steps, update the current state of every scroll-state query container. This snapshotted state will be used for any style and layout updates until the next time these steps are run.

We should consider a similar approach here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants