Skip to content

Commit 4e65307

Browse files
authored
Merge pull request #50 from mgiuca/empty-dict-error
spec: Throw a TypeError if all fields are missing.
2 parents 3ca51ba + 0c7a74d commit 4e65307

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

index.html

+61
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ <h4>
118118
<li>Let <var>p</var> be <a data-cite=
119119
"!promises-guide#a-new-promise">a new promise</a>.
120120
</li>
121+
<li>If none of <var>data</var>'s members <a for=
122+
"ShareData">title</a>, <a for="ShareData">text</a>, or <a for=
123+
"ShareData">url</a> are present, reject <var>p</var> with
124+
<a data-cite=
125+
"!WEBIDL#exceptiondef-typeerror"><code>TypeError</code></a>, and
126+
abort these steps.
127+
</li>
121128
<li>If <var>data</var>'s <a for="ShareData">url</a> member is
122129
<a data-cite="!WEBIDL#dfn-present">present</a>:
123130
<ol>
@@ -381,6 +388,60 @@ <h2>
381388
</li>
382389
</ul>
383390
</section>
391+
<section class="appendix informative">
392+
<h2>
393+
Extensibility of this API
394+
</h2>
395+
<p>
396+
The Web Share API is designed to be extended in the future by way of
397+
new members added to to the <a>ShareData</a> dictionary, to allow both
398+
sharing of new types of data (<i>e.g.</i>, <a href=
399+
"https://github.com/WICG/web-share/issues/12">images</a>) and strings
400+
with new semantics (<i>e.g.</i> author).
401+
</p>
402+
<div class="warning">
403+
This doesn't mean user agents can add whatever members they like. It
404+
means that new members can be added to the standard in the future.
405+
</div>
406+
<p>
407+
The three members <a for="ShareData">title</a>, <a for=
408+
"ShareData">text</a>, and <a for="ShareData">url</a>, are part of the
409+
base feature set, and implementations that provide
410+
<a><code>navigator.share</code></a> need to accept all three. Any new
411+
members that are added in the future will be <em>individually
412+
feature-detectable</em>, to allow for backwards-compatibility with
413+
older implementations that don't recognise those members. These new
414+
members might also be added as optional "MAY" requirements.
415+
</p>
416+
<div class="note">
417+
There is <a href="https://github.com/heycam/webidl/issues/107">an open
418+
discussion</a> about how to provide feature-detection for dictionary
419+
members. Web Share will use the mechanism produced by that discussion.
420+
</div>
421+
<p>
422+
The <a for="Navigator"><code>share</code></a> method throws a
423+
<a data-cite=
424+
"!WEBIDL#exceptiondef-typeerror"><code>TypeError</code></a> if none of
425+
the specified members are present. The intention is that when a new
426+
member is added, it will also be added to this list of recognised
427+
members (so as to not throw an error). This is for future-proofing
428+
implementations: if a web site written against a future version of this
429+
spec uses <em>only</em> new members (<i>e.g.</i>,
430+
<code>navigator.share({image: x})</code>), it will be valid in future
431+
user agents, but a <a data-cite=
432+
"!WEBIDL#exceptiondef-typeerror"><code>TypeError</code></a> on user
433+
agents implementing an older version of the spec. Developers will be
434+
asked to feature-detect any new fields they rely on, to avoid having
435+
errors surface in their program.
436+
</p>
437+
<p>
438+
Editors of this spec will want to carefully consider the genericity of
439+
any new members being added, avoiding fields that are closely
440+
associated with a particular service, user agent or operating system,
441+
in favour of fields that can potentially be applied to a wide range of
442+
platforms and targets.
443+
</p>
444+
</section>
384445
<section class="appendix">
385446
<h2>
386447
Acknowledgments

0 commit comments

Comments
 (0)