Skip to content

[css-view-transitions] Making the callback param non-nullable #9460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vmpstr opened this issue Oct 12, 2023 · 1 comment · Fixed by #9493
Closed

[css-view-transitions] Making the callback param non-nullable #9460

vmpstr opened this issue Oct 12, 2023 · 1 comment · Fixed by #9493
Labels
css-view-transitions-1 View Transitions; Bugs only css-view-transitions-2 View Transitions; New feature requests Needs Edits

Comments

@vmpstr
Copy link
Member

vmpstr commented Oct 12, 2023

In css-view-transitions, we define the following, an optional nullable callback with the default value of null:

partial interface Document {
  ViewTransition startViewTransition(optional UpdateCallback? updateCallback = null);
};

In #8960 we resolved to change the callback (in Level 2) to take either a callback or a dictionary of options. Naively, this would have been the following

ViewTransition startViewtransition(optional (UpdateCallback or Dictionary)? param = null)

But that's not possible because of the following restriction:

A nullable type is an IDL type constructed from an existing type (called the inner type) [...] The inner type must not be:

A simple solution is to just make these non-nullable:

ViewTransition startViewtransition(optional (UpdateCallback or Dictionary) param)

Additionally, for consistency, it would be nice to make the existing view transition callback non nullable as well, while still remaining optional:

ViewTransition startViewtransition(optional UpdateCallback updateCallback)

I believe the only script visible change here is that this would preclude startViewTransition(null) from being valid. I could be wrong though. If I'm right, then I think that's fine, since that doesn't seem like a correct use of this API.

@vmpstr vmpstr added css-view-transitions-1 View Transitions; Bugs only css-view-transitions-2 View Transitions; New feature requests Agenda+ labels Oct 12, 2023
@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-view-transitions] Making the callback param non-nullable, and agreed to the following:

  • RESOLVED: Make the parameter non-nullable, but keep it optional
The full IRC log of that discussion <emilio> noamr: we have a startViewTransition call that takes one param that is marked as optional nullable with default of null
<emilio> ... we resolved to extend this to allow a dictionary
<emilio> ... so naively it'd be an optional nullable union
<emilio> ... but that's not possible in WebIDL
<noamr> it's vmpstr, not noamr
<emilio> vmpstr: so proposal is making it non-nullable
<emilio> ... this only precludes null of being a valid parameter
<emilio> ... it'd still be optional
<emilio> astearns: if we decide on null as a naive way of dealing with the optionality?
<emilio> ... was there a purpose?
<emilio> vmpstr: there wasn't, it was just in the editor's draft since the beginning
<khush> +1
<emilio> q+
<khush> q+
<astearns> emilio: so if null is passed we will start throwing?
<astearns> ack emilio
<emilio> vmpstr: that's right
<emilio> emilio: hopefully nobody is doing that, if you're fine with the compat risk seems fine
<emilio> vmpstr: usage is low enough
<emilio> emilio: sounds good then
<emilio> khush: to add to vmpstr there's no production usecase where you'd do that
<emilio> ... because the callback is where you are supposed to mutate the DOM
<emilio> vmpstr: to clarify it's still optional, it'd be just explicit null that could be problematic
<emilio> RESOLVED: Make the parameter non-nullable, but keep it optional

vmpstr added a commit to vmpstr/csswg-drafts that referenced this issue Oct 18, 2023
vmpstr added a commit that referenced this issue Oct 18, 2023
aarongable pushed a commit to chromium/chromium that referenced this issue Oct 18, 2023
This addresses the following resolution:
w3c/csswg-drafts#9460

[email protected], [email protected]

Change-Id: I94b428dad2bc2946d083036a2bf3fe9c87ed2beb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4951161
Reviewed-by: Khushal Sagar <[email protected]>
Commit-Queue: Vladimir Levin <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1211715}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-view-transitions-1 View Transitions; Bugs only css-view-transitions-2 View Transitions; New feature requests Needs Edits
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants