Skip to content

Commit 0c8e0c1

Browse files
author
Marcos Cáceres
authored
Introduce [[sharePromise]] internal slot (#113)
1 parent b685953 commit 0c8e0c1

File tree

1 file changed

+63
-13
lines changed

1 file changed

+63
-13
lines changed

index.html

+63-13
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ <h3>
104104
target</a>. Clients can use the presence or absence of this method to
105105
determine whether to show UI that triggers its use.
106106
</div>
107+
<section>
108+
<h4>
109+
Internal Slots
110+
</h4>
111+
<p>
112+
This API adds the following internal slot to the {{Navigator}}
113+
interface.
114+
</p>
115+
<dl>
116+
<dt>
117+
{{Promise}}? <dfn>[[\sharePromise]]</dfn>
118+
</dt>
119+
<dd>
120+
The {{[[sharePromise]]}} is a promise that represents a user's
121+
current intent to share some data with a <a>share target</a>. It
122+
is initialized to `null`.
123+
</dd>
124+
</dl>
125+
</section>
107126
<section>
108127
<h4>
109128
<dfn>share()</dfn> method
@@ -113,6 +132,9 @@ <h4>
113132
|data:ShareData|, run the following steps:
114133
</p>
115134
<ol class="algorithm">
135+
<li>If {{[[sharePromise]]}} is not `null`, return <a>a promise
136+
rejected with</a> {{InvalidStateError}}.
137+
</li>
116138
<li>If none of |data|'s members {{ShareData/title}},
117139
{{ShareData/text}}, or {{ShareData/url}} are present, return <a>a
118140
promise rejected with</a> a {{TypeError}}.
@@ -140,32 +162,60 @@ <h4>
140162
return <a>a promise rejected with</a> with a {{"NotAllowedError"}}
141163
{{DOMException}}.
142164
</li>
143-
<li>Let |p:Promise| be <a>a new promise</a>.
165+
<li>Set {{[[sharePromise]]}} to be <a>a new promise</a>.
144166
</li>
145-
<li>Return |p| and <a>in parallel</a>:
167+
<li>Return {{[[sharePromise]]}} and <a>in parallel</a>:
146168
<ol>
147-
<li>If there are no <a>share targets</a> available,
148-
<a>reject</a> |p| with an {{"AbortError"}} {{DOMException}},
149-
and abort these steps.
169+
<li>If there are no <a>share targets</a> available:
170+
<ol>
171+
<li>
172+
<a>Reject</a> {{[[sharePromise]]}} with an
173+
"{{AbortError}}" {{DOMException}}.
174+
</li>
175+
<li>Set {{[[sharePromise]]}} to `null`.
176+
</li>
177+
<li>Abort these steps.
178+
</li>
179+
</ol>
150180
</li>
151181
<li>Present the user with a choice of one or more <a>share
152182
targets</a>, selected at the user agent's discretion. The user
153183
MUST be given the option to cancel rather than choosing any of
154184
the share targets. Wait for the user's choice.
155185
</li>
156-
<li>If the user chose to cancel the share operation,
157-
<a>reject</a> |p| with an {{"AbortError"}} {{DOMException}},
158-
and abort these steps.
186+
<li>If the user chose to cancel the share operation:
187+
<ol>
188+
<li>
189+
<a>Reject</a> {{[[sharePromise]]}} with an
190+
"{{AbortError}}" {{DOMException}},
191+
</li>
192+
<li>Set {{[[sharePromise]]}} to `null`.
193+
</li>
194+
<li>Abort these steps.
195+
</li>
196+
</ol>
159197
</li>
160198
<li>Activate the chosen <a>share target</a>, <a>convert |data|
161199
to a format suitable for ingestion into the target</a>, and
162-
transmit the converted data to the target. If an error occurs
163-
starting the target or transmitting the data, <a>reject</a> |p|
164-
with an {{"AbortError"}} {{DOMException}}, and abort these
165-
steps.
200+
transmit the converted data to the target.
201+
</li>
202+
<li>If an error occurs starting the target or transmitting the
203+
data:
204+
<ol>
205+
<li>
206+
<a>reject</a> {{[[sharePromise]]}} with an
207+
"{{DataError}}" {{DOMException}}, and abort these steps.
208+
</li>
209+
<li>Set {{[[sharePromise]]}} to `null`.
210+
</li>
211+
<li>Abort these steps.
212+
</li>
213+
</ol>
166214
</li>
167215
<li>Once the data has been successfully transmitted to the
168-
target, <a>resolve</a> |p| with <b>undefined</b>.
216+
target, <a>resolve</a> {{[[sharePromise]]}} with `undefined`.
217+
</li>
218+
<li>Set {{[[sharePromise]]}} to `null`.
169219
</li>
170220
</ol>
171221
</li>

0 commit comments

Comments
 (0)