Skip to content

Comments

Content update & fix of Notification in Service Worker#32099

Merged
wbamberg merged 15 commits intomdn:mainfrom
skyclouds2001:notification-service-worker
Feb 9, 2024
Merged

Content update & fix of Notification in Service Worker#32099
wbamberg merged 15 commits intomdn:mainfrom
skyclouds2001:notification-service-worker

Conversation

@skyclouds2001
Copy link
Contributor

Description

move the note in ServiceWorkerGlobalScope.notificationclose event to Notification() constructor

and update content indicating relative event on Notification in ServiceWorkerGlobalScope.notificationclick

also update example description by replacing event handler property usage to event

Motivation

Additional details

Related issues and pull requests

@github-actions github-actions bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Feb 3, 2024
@skyclouds2001 skyclouds2001 marked this pull request as ready for review February 3, 2024 18:09
@skyclouds2001 skyclouds2001 requested a review from a team as a code owner February 3, 2024 18:09
@skyclouds2001 skyclouds2001 requested review from wbamberg and removed request for a team February 3, 2024 18:09
@skyclouds2001 skyclouds2001 changed the title Content update of Notification in Service Worker Content update & fix of Notification in Service Worker Feb 7, 2024
- `title`
- : A string containing action text to be shown to the user.
- `icon`
- `icon` {{optional_inline}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Flyby. If the parent is optional, aren't all of the sub items (i.e why not action and title too)? Or are you saying that IFF actions is specified, then the action and title must be specified, but icon is optional?

Copy link
Collaborator

Choose a reason for hiding this comment

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

IFF actions is specified, then the action and title must be specified, but icon is optional?

Basically, yes:

Copy link
Collaborator

Choose a reason for hiding this comment

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

Although weirdly it seems as if, if you call this constructor, you must not pass any actions, or you get a TypeError exception? https://notifications.spec.whatwg.org/#create-a-notification

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks.

Although weirdly it seems as if, if you call this constructor, you must not pass any actions, or you get a TypeError exception? https://notifications.spec.whatwg.org/#create-a-notification

It says "If a serviceWorkerRegistration was not provided and options["actions"] is not empty, then throw a TypeError."

So you you can only have actions if the serviceworker registration is provided.

Looking through this there are lots of missing cases that can throw a typerror

Copy link
Collaborator

Choose a reason for hiding this comment

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

So you you can only have actions if the serviceworker registration is provided.

Right, but that operation I linked, https://notifications.spec.whatwg.org/#create-a-notification , can I think be reached from two paths:

...and it's only in the second of these cases that the registration gets passed. So if you call the constructor, you must not provide actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, but that operation I linked, https://notifications.spec.whatwg.org/#create-a-notification , can I think be reached from two paths:

...and it's only in the second of these cases that the registration gets passed. So if you call the constructor, you must not provide actions.

yes, actions parameter can not use with Notification() constructor

- `title`
- : A string containing action text to be shown to the user.
- `icon`
- `icon` {{optional_inline}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Although weirdly it seems as if, if you call this constructor, you must not pass any actions, or you get a TypeError exception? https://notifications.spec.whatwg.org/#create-a-notification

Co-authored-by: wbamberg <will@bootbonnet.ca>
Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

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

👍 thank you!

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

Labels

Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants