Re: [w3c/ServiceWorker] consider allowing a non-scope identifier for registrations (#1512)

> Do we have an existing API that follows this mixed pattern?

`<element id="foo">` is an optional identifier.

> This seems like a good plan, good enough that web developers might not feel the need to set IDs very often.

I would argue it would be a best practice to set an id if you are using a pattern or pattern list.  This makes me more inclined to go with your previous suggestion of requiring the id in those cases.

> What is the advantage of passing an ID instead of a scope?

I think the id is much more developer friendly.  Typing a serialized scope list may not be very easy or readable.  Also, an API which requires you to type the list as it was and the list as it will is going to be very verbose.  Allowing the developer to provide a meaningful product name like "my-product-foo" is going to be a lot more ergonomic.

Also, the id makes it clear we are modifying a single registration and not creating a new registration to replace an old one.  This is important when you consider other state that sits in managers (push, nav preload, etc) attached to the registration.  We don't want to lose all that when the scope changes.

Finally, I think its just bad design to allow mutation of the scope on a registration and also try to keep using it as a key.  How is the spec supposed to sanely deal with a registration where the active worker is scope A and the installing worker is for scope B?  We need a stable, immutable key.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1512#issuecomment-710422372

Received on Friday, 16 October 2020 18:53:11 UTC