Re: [csswg-drafts] [css-view-transitions-2] Allow an auto-generated `view-transition-name` that doesn't default to ID (#10995)

This conversation has stalled, so let’s bring it back to life.

Summary up until now is that `auto` should be put on hold until we get a better idea about what it should do, and that `match-element` is to be used for identity matching. Input is being asked from @nt1m, @fantasai, and @emilio.

---

Personally I would like to _not_ use `match-element` to generate an internal identifier _(unobservable by authors)_ but assign that behavior to the `auto` keyword.

This for two reasons:

1. You can get the originally requested auto-behavior (the one that first tries the `id` attribute, falling back to an internally generated identifier) using `attr()`:
  
    ```css
    view-transition-name: attr(id type(<ident>), auto);
    ```
    
    Yes, it’s a bit of extra typing but:
        - It works with attributes other than `id` too
        - Authors are being very explicit about what they want
        - It can always be backported into a keyword _(or function preferably, see “feature detection” point below)_

2. Feature detection

    If you feature detect `view-transition-name: match-element` with `@supports`/`CSS.supports` it currently returns `true`. 
  
    ```css
    @supports (view-transition-name: match-element) {
      .item {
        view-transition-name: match-element;
      }
    }
    ```

    The snippet above will pass in both Chrome and Safari today already _(uhoh!)_, resulting in multiple elements getting a `view-transition-name` set to `match-element` which will prevent the View Transition from running.

    ```
    Unexpected duplicate view-transition-name: match-element
    <div class=​"item" id=​"item-1">​…​</div>​
    <div class=​"item" id=​"item-2">​…​</div>​
    <div class=​"item" id=​"item-3">​…​</div>​
    <div class=​"item" id=​"item-4">​…​</div>​
    <div class=​"item" id=​"item-5">​…​</div>​
    ```

    As a result an author can not safely feature detect support for `match-element`.
    
    When feature detecting `view-transition-name: auto` it return `false` (*), which would allow author to feature-detect `auto` having some magic behavior instead of it being the actual `view-transition-name` that gets assigned.
    
    (*) Unfortunately only in Safari. Chrome returns `true` here, which would need to get fixed – see https://crbug.com/383409588 which I filed just now.

    (Alternatively changing `match-element` to become a function (i.e `match-element()` would also fix this feature detection issue)
  


-- 
GitHub Notification of comment by bramus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10995#issuecomment-2536191408 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 11 December 2024 14:42:38 UTC