Skip to content

Commit 0fd4b82

Browse files
authored
Editorial: modernize the language around actions
This will make it easier to give them more associated concepts.
1 parent 96a2c28 commit 0fd4b82

File tree

1 file changed

+45
-33
lines changed

1 file changed

+45
-33
lines changed

notifications.bs

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,27 @@ the <a>notification</a>, but then it should have less visual priority than the
124124
is not otherwise accessible to the end user, especially since notification platforms that do not
125125
support these features might ignore them.
126126

127-
<p>A <a>notification</a> has an associated list of
128-
zero or more <dfn for=notification lt=action id=actions>actions</dfn>. Each
129-
<a for=notification>action</a> has an associated
130-
<dfn for=action id=action-title>title</dfn> and <dfn for=action id=action-name>name</dfn> and
131-
<em>can</em> have an associated <dfn for=action>icon URL</dfn> and
132-
<dfn for=action>icon resource</dfn>. Users may activate actions, as alternatives to
133-
activating the notification itself. The user agent must determine the
134-
<dfn>maximum number of actions</dfn> supported, within the constraints of the
135-
notification platform.
127+
<p>A <a>notification</a> has associated <dfn for=notification id=actions>actions</dfn> (a
128+
<a for=/>list</a> of zero or more <a for=/>actions</a>). An <dfn>action</dfn> represents a choice
129+
for an end user. Each <a for=/>action</a> has an associated:
130+
131+
<dl>
132+
<dt><dfn for=action id=action-title>title</dfn>
133+
<dd>A string.
134+
135+
<dt><dfn for=action id=action-name>name</dfn>
136+
<dd>A string.
137+
138+
<dt><dfn for=action>icon URL</dfn>
139+
<dd>Null or a <a for=/>URL</a>. It is initially null.
140+
141+
<dt><dfn for=action>icon resource</dfn>
142+
<dd>Null or a resource. It is initially null.
143+
</dl>
144+
145+
<p>Users may activate actions, as alternatives to activating the notification itself. The
146+
<dfn>maximum number of actions</dfn> supported is an <a>implementation-defined</a> integer of zero
147+
or more, within the constraints of the notification platform.
136148

137149
<p class=note>Since display of actions is platform-dependent, developers are
138150
encouraged to make sure that any action a user can invoke from a notification is
@@ -239,13 +251,14 @@ string <var>title</var>, {{NotificationOptions}} <a for=/>dictionary</a> <var>op
239251
<li><p>Set <var>notification</var>'s <a for=notification>require interaction preference</a> to
240252
<var>options</var>["{{NotificationOptions/requireInteraction}}"].
241253

254+
<li><p>Set <var>notification</var>'s <a for=notification>actions</a> to « ».
255+
242256
<li>
243-
<p>Set <var>notification</var>'s list of <a>actions</a> to an empty list, then for each
244-
<var>entry</var> in <var>options</var>["{{NotificationOptions/actions}}"], up to the
257+
<p>For each <var>entry</var> in <var>options</var>["{{NotificationOptions/actions}}"], up to the
245258
<a>maximum number of actions</a> supported (skip any excess entries):
246259

247260
<ol>
248-
<li><p>Let <var>action</var> be a new <a lt="actions">action</a>.
261+
<li><p>Let <var>action</var> be a new <a for=/>action</a>.
249262

250263
<li><p>Set <var>action</var>'s <a for=action>name</a> to
251264
<var>entry</var>["{{NotificationAction/action}}"].
@@ -256,9 +269,9 @@ string <var>title</var>, {{NotificationOptions}} <a for=/>dictionary</a> <var>op
256269
<li><p>If <var>entry</var>["{{NotificationAction/icon}}"] <a for=map>exists</a>, then
257270
<a lt="url parser">parse</a> it using <var>baseURL</var>, and if that does not return failure,
258271
set <var>action</var>'s <a for=action>icon URL</a> to the return value. (Otherwise
259-
<a for=action>icon URL</a> is not set.)
272+
<a for=action>icon URL</a> remains null.)
260273

261-
<li><p>Append <var>action</var> to <var>notification</var>'s list of <a>actions</a>.
274+
<li><p>Append <var>action</var> to <var>notification</var>'s <a for=notification>actions</a>.
262275
</ol>
263276

264277
<li><p>Return <var>notification</var>.
@@ -420,12 +433,12 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[!
420433

421434
<li>
422435
<p>If the notification platform supports actions and action icons, then for each <var>action</var>
423-
in <var>notification</var>'s list of <a>actions</a> <a for=/>fetch</a> <var>action</var>'s
424-
<a for=action>icon URL</a>, if <a for=action>icon URL</a> is set.
436+
in <var>notification</var>'s <a for=notification>actions</a>: if <a for=action>icon URL</a> is
437+
non-null, <a for=/>fetch</a> <var>action</var>'s <a for=action>icon URL</a>.
425438

426439
<p class=note>The intent is to fetch this resource similar to an
427440
<a href="https://html.spec.whatwg.org/multipage/images.html#update-the-image-data"><code>&lt;img&gt;</code></a>,
428-
but this <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=24055">needs abstracting</a>.
441+
but this <a href="https://github.com/whatwg/html/issues/4474">needs abstracting</a>.
429442

430443
<p>Then, <a>in parallel</a>:
431444

@@ -435,9 +448,9 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[!
435448
<li><p>If the <a for=/>response</a>'s <a>internal response</a>'s <a for=response>type</a> is
436449
"<code>default</code>", then attempt to decode the resource as image.
437450

438-
<li><p>If the image format is supported, set <var>action</var>'s
439-
<a for=action>icon resource</a> to the decoded resource. (Otherwise
440-
<var>action</var> has no <a for=action>icon resource</a>.)
451+
<li><p>If the image format is supported, then set <var>action</var>'s
452+
<a for=action>icon resource</a> to the decoded resource. (Otherwise <var>action</var>'s
453+
<a for=action>icon resource</a> remains null.)
441454
</ol>
442455
</li>
443456
</ol>
@@ -509,10 +522,9 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[!
509522

510523
<h3 id=activating-a-notification>Activating a notification</h3>
511524

512-
<p>When a <a>notification</a> <var>notification</var>,
513-
or one of its <a>actions</a>, is activated by the user, assuming the underlying
514-
notification platform supports activation, the user agent must (unless otherwise
515-
specified) run these steps:
525+
<p>When a <a>notification</a> <var>notification</var>, or one of its
526+
<a for=notification>actions</a>, is activated by the user, assuming the underlying notification
527+
platform supports activation, the user agent must (unless otherwise specified) run these steps:
516528

517529
<ol>
518530
<li>
@@ -522,7 +534,7 @@ specified) run these steps:
522534
<li><p>Let <var>action</var> be the empty string.
523535

524536
<li><p>If one of <var>notification</var>'s <a for=notification>actions</a> was activated by the
525-
user, then set <var>action</var> to that <a for=notification>action</a>'s <a for=action>name</a>.
537+
user, then set <var>action</var> to that <a for=/>action</a>'s <a for=action>name</a>.
526538

527539
<li><a>Fire a service worker notification event</a> named "<code>notificationclick</code>" given
528540
<var>notification</var> and <var>action</var>.
@@ -872,7 +884,7 @@ then return null.
872884
<li><p>Let <var>frozenActions</var> be an empty list of type {{NotificationAction}}.
873885

874886
<li>
875-
<p><a for=list>For each</a> <var>entry</var> of <a>this</a>'s <a>notification</a>'s list of
887+
<p><a for=list>For each</a> <var>entry</var> of <a>this</a>'s <a>notification</a>'s
876888
<a for=notification>actions</a>:
877889

878890
<ol>
@@ -884,8 +896,9 @@ then return null.
884896
<li><p>Set <var>action</var>["{{NotificationAction/title}}"] to <var>entry</var>'s
885897
<a for=action>title</a>.
886898

887-
<li><p>Set <var>action</var>["{{NotificationAction/icon}}"] <var>entry</var>'s
888-
<a for=action>icon URL</a>.
899+
<li><p>If <var>entry</var>'s <a for=action>icon URL</a> is non-null, then set
900+
<var>action</var>["{{NotificationAction/icon}}"] to <var>entry</var>'s
901+
<a for=action>icon URL</a>, <a lt="URL serializer">serialized</a>.
889902

890903
<!-- XXX IDL dictionaries are usually returned by value, so don't need to be
891904
immutable. But FrozenArray reifies the dictionaries to mutable JS
@@ -922,11 +935,10 @@ not.onclick = function() { displaySong(this); };</pre>
922935
<p><a lt="persistent notification">Persistent notifications</a> fire
923936
<code>notificationclick</code> events on the {{ServiceWorkerGlobalScope}}.
924937

925-
<p>Here a service worker shows a notification with a single "Archive"
926-
<a lt="actions">action</a>, allowing users to perform this common task from the
927-
notification without having to open the website (for example the notification
928-
platform might show a button on the notification). The user can also activate
929-
the main body of the notification to open their inbox.
938+
<p>Here a service worker shows a notification with a single "Archive" <a for=/>action</a>, allowing
939+
users to perform this common task from the notification without having to open the website (for
940+
example the, notification platform might show a button on the notification). The user can also
941+
activate the main body of the notification to open their inbox.
930942

931943
<pre class=example id=example-50e7c86c>
932944
self.registration.showNotification("New mail from Alice", {

0 commit comments

Comments
 (0)