You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
draft document and may be updated, replaced or obsoleted by other documents
749
749
at any time. It is inappropriate to cite this document as other than work in
750
750
progress. </p>
751
-
<p></p>
752
751
<p> Feedback and comments on this document are welcome. Please <ahref="https://github.com/w3ctag/design-principles/issues">file an issue</a> in this document’s <ahref="https://github.com/w3ctag/design-principles/">GitHub repository</a>. </p>
753
752
<p> This document is governed by the <ahref="https://www.w3.org/policies/process/20231103/" id="w3c_process_revision">03 November 2023 W3C
websites should not be able to detect that private browsing mode is engaged.</p>
1450
1449
<divclass="example" id="example-52cad010"><aclass="self-link" href="#example-52cad010"></a> User Agents which support <ahref="https://www.w3.org/TR/IndexedDB/">IndexedDB</a> should not disable it in private browsing mode,
1451
1450
because that would reveal that private browsing mode is engaged </div>
1452
-
<divclass="example" id="example-bc7df47d">
1453
-
<aclass="self-link" href="#example-bc7df47d"></a> The <ahref="https://www.w3.org/TR/payment-request/">Payment Request API</a>'s <ahref="https://www.w3.org/TR/payment-request/#show-method">show() method</a>,
1451
+
<divclass="example" id="example-26556da1">
1452
+
<aclass="self-link" href="#example-26556da1"></a> The <ahref="https://www.w3.org/TR/payment-request/">Payment Request API</a>’s <ahref="https://www.w3.org/TR/payment-request/#show-method">show() method</a>,
1454
1453
when called,
1455
1454
allows User Agents <qcite="https://www.w3.org/TR/payment-request/#show-method">to act
1456
1455
as if the user had immediately <ahref="https://www.w3.org/TR/payment-request/#dfn-user-aborts-the-payment-request">aborted the payment request</a></q>.
<divclass="note" role="note"> This does not hold the other way around.
1763
1762
A new IDL attribute does not always warrant a content attribute counterpart. </div>
1764
-
<divclass="example" id="example-ae20f706"><aclass="self-link" href="#example-ae20f706"></a> A counterpattern to this guidance can be found in <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/input.html#the-input-element" id="ref-for-the-input-element④">input</a></code>'s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/input.html#attr-input-value" id="ref-for-attr-input-value">value</a></code>, <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/form-elements.html#the-option-element" id="ref-for-the-option-element①">option</a></code>'s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/form-elements.html#attr-option-selected" id="ref-for-attr-option-selected">selected</a></code>, and <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/input.html#the-input-element" id="ref-for-the-input-element⑤">input</a></code>'s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/input.html#attr-input-checked" id="ref-for-attr-input-checked">checked</a></code> where the HTML attributes were never updated
1763
+
<divclass="example" id="example-6013821e"><aclass="self-link" href="#example-6013821e"></a> A counterpattern to this guidance can be found in <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/input.html#the-input-element" id="ref-for-the-input-element④">input</a></code>’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/input.html#attr-input-value" id="ref-for-attr-input-value">value</a></code>, <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/form-elements.html#the-option-element" id="ref-for-the-option-element①">option</a></code>’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/form-elements.html#attr-option-selected" id="ref-for-attr-option-selected">selected</a></code>, and <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/input.html#the-input-element" id="ref-for-the-input-element⑤">input</a></code>’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/input.html#attr-input-checked" id="ref-for-attr-input-checked">checked</a></code> where the HTML attributes were never updated
1765
1764
and the IDL attribute was the single source of truth. </div>
1766
1765
<h3class="heading settled" data-level="3.6" id="naming-of-url-attributes"><spanclass="secno">3.6. </span><spanclass="content">Name URL-containing attributes based on their primary purpose</span><aclass="self-link" href="#naming-of-url-attributes"></a></h3>
1767
1766
<p>If the element enables the user to navigate to the URL contained in the attribute, call the attribute <code>href</code>, like the <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element" id="ref-for-the-a-element">a</a></code> element’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/links.html#attr-hyperlink-href" id="ref-for-attr-hyperlink-href">href</a></code> attribute.</p>
1768
-
<pclass="note" role="note"><spanclass="marker">Note:</span> In hindsight, <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/forms.html#the-form-element" id="ref-for-the-form-element">form</a></code>'s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-action" id="ref-for-attr-fs-action">action</a></code> attribute should have been named <code>href</code>.</p>
1767
+
<pclass="note" role="note"><spanclass="marker">Note:</span> In hindsight, <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/forms.html#the-form-element" id="ref-for-the-form-element">form</a></code>’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-action" id="ref-for-attr-fs-action">action</a></code> attribute should have been named <code>href</code>.</p>
1769
1768
<p>If the element causes the resource at the given URL to be loaded, call the attribute <code>src</code>, like the <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element" id="ref-for-the-img-element①">img</a></code> element’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-src" id="ref-for-attr-img-src">src</a></code> attribute or the <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/scripting.html#script" id="ref-for-script①">script</a></code> element’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/scripting.html#attr-script-src" id="ref-for-attr-script-src">src</a></code> attribute.</p>
1770
-
<pclass="note" role="note"><spanclass="marker">Note:</span> HTML has a number of legacy inconsistencies that should not be emulated, like the way <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/semantics.html#the-link-element" id="ref-for-the-link-element①">link</a></code>'s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/semantics.html#attr-link-href" id="ref-for-attr-link-href">href</a></code> attribute might allow for navigation or for resource loading, depending on the value of the element’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/semantics.html#attr-link-rel" id="ref-for-attr-link-rel">rel</a></code> attribute. </p>
1771
-
<p>If the attribute identifies a URL that is auxilliary to the element’s purpose, like <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/media.html#video" id="ref-for-video①">video</a></code>'s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/media.html#attr-video-poster" id="ref-for-attr-video-poster">poster</a></code>, <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-q-element" id="ref-for-the-q-element">q</a></code>'s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#attr-q-cite" id="ref-for-attr-q-cite">cite</a></code>, or <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element" id="ref-for-the-a-element①">a</a></code>’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/links.html#ping" id="ref-for-ping">ping</a></code>, name the attribute after its semantics.</p>
1769
+
<pclass="note" role="note"><spanclass="marker">Note:</span> HTML has a number of legacy inconsistencies that should not be emulated, like the way <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/semantics.html#the-link-element" id="ref-for-the-link-element①">link</a></code>’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/semantics.html#attr-link-href" id="ref-for-attr-link-href">href</a></code> attribute might allow for navigation or for resource loading, depending on the value of the element’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/semantics.html#attr-link-rel" id="ref-for-attr-link-rel">rel</a></code> attribute. </p>
1770
+
<p>If the attribute identifies a URL that is auxilliary to the element’s purpose, like <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/media.html#video" id="ref-for-video①">video</a></code>’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/media.html#attr-video-poster" id="ref-for-attr-video-poster">poster</a></code>, <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-q-element" id="ref-for-the-q-element">q</a></code>’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#attr-q-cite" id="ref-for-attr-q-cite">cite</a></code>, or <code><adata-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element" id="ref-for-the-a-element①">a</a></code>’s <code><adata-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/links.html#ping" id="ref-for-ping">ping</a></code>, name the attribute after its semantics.</p>
1772
1771
<pclass="note" role="note"><spanclass="marker">Note:</span> remember that attributes containing URLs should be represented in IDL as <codeclass="idl"><adata-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-USVString" id="ref-for-idl-USVString">USVString</a></code>; see <ahref="#idl-string-types">§ 8.2 Represent strings appropriately</a>.</p>
1773
1772
<h3class="heading settled" data-level="3.7" id="html-overloading"><spanclass="secno">3.7. </span><spanclass="content">Give each HTML element a single purpose</span><aclass="self-link" href="#html-overloading"></a></h3>
causing the same event handler to be fired, and so on.</p>
2582
2581
<p>To prevent this, make sure that any "recursive" call into the API method
2583
2582
simply returns immediately. This technique is "guarding" the algorithm.</p>
2584
-
<divclass="example" id="example-685bd37b">
2585
-
<aclass="self-link" href="#example-685bd37b"></a><codeclass="idl"><adata-link-type="idl" href="https://dom.spec.whatwg.org/#abortsignal" id="ref-for-abortsignal①">AbortSignal</a></code>'s <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortsignal-add" id="ref-for-abortsignal-add">add</a>, <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortsignal-remove" id="ref-for-abortsignal-remove">remove</a> and <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortcontroller-signal-abort" id="ref-for-abortcontroller-signal-abort">signal abort</a> each begin with a check to see if the signal is <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortsignal-aborted" id="ref-for-abortsignal-aborted">aborted</a>.
2583
+
<divclass="example" id="example-ce590887">
2584
+
<aclass="self-link" href="#example-ce590887"></a><codeclass="idl"><adata-link-type="idl" href="https://dom.spec.whatwg.org/#abortsignal" id="ref-for-abortsignal①">AbortSignal</a></code>’s <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortsignal-add" id="ref-for-abortsignal-add">add</a>, <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortsignal-remove" id="ref-for-abortsignal-remove">remove</a> and <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortcontroller-signal-abort" id="ref-for-abortcontroller-signal-abort">signal abort</a> each begin with a check to see if the signal is <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortsignal-aborted" id="ref-for-abortsignal-aborted">aborted</a>.
2586
2585
If the signal is <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortsignal-aborted" id="ref-for-abortsignal-aborted①">aborted</a>, the rest of the algorithm doesn’t run.
2587
2586
<p>In this case, a lot of the important complexity is
2588
2587
in the algorithms run during the <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortcontroller-signal-abort" id="ref-for-abortcontroller-signal-abort①">signal abort</a> steps.
2589
2588
These steps iterate through a collection of algorithms
2590
2589
which are managed by the <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortsignal-add" id="ref-for-abortsignal-add①">add</a> and <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortsignal-remove" id="ref-for-abortsignal-remove①">remove</a> methods.</p>
2591
2590
<p>For example, the <ahref="https://streams.spec.whatwg.org/#readable-stream-pipe-to">ReadableStreamPipeTo</a> definition <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortsignal-add" id="ref-for-abortsignal-add②">add</a>s an algorithm
2592
-
into the <codeclass="idl"><adata-link-type="idl" href="https://dom.spec.whatwg.org/#abortsignal" id="ref-for-abortsignal②">AbortSignal</a></code>'s set of algorithms to be run
2591
+
into the <codeclass="idl"><adata-link-type="idl" href="https://dom.spec.whatwg.org/#abortsignal" id="ref-for-abortsignal②">AbortSignal</a></code>’s set of algorithms to be run
2593
2592
when the <adata-link-type="dfn" href="https://dom.spec.whatwg.org/#abortcontroller-signal-abort" id="ref-for-abortcontroller-signal-abort②">signal abort</a> steps are triggered,
2594
2593
by calling <codeclass="idl"><adata-link-type="idl" href="https://dom.spec.whatwg.org/#dom-abortcontroller-abort" id="ref-for-dom-abortcontroller-abort①">abort()</a></code> on the <codeclass="idl"><adata-link-type="idl" href="https://dom.spec.whatwg.org/#abortcontroller" id="ref-for-abortcontroller①">AbortController</a></code> associated with the signal.</p>
2595
2594
<p>This algorithm is likely to resolve promises causing code to run,
the behavior of inspecting or changing state is well-defined.</p>
2665
2664
<p><spanclass="informative">For example, in <adata-link-type="biblio" href="#biblio-payment-request" title="Payment Request API">[payment-request]</a>,
2666
-
the <codeclass="idl"><adata-link-type="idl" href="https://w3c.github.io/payment-request/#dom-paymentrequest" id="ref-for-dom-paymentrequest">PaymentRequest</a></code>'s <adata-link-type="dfn" href="https://www.w3.org/TR/payment-request/#dfn-state" id="ref-for-dfn-state">[[state]]</a> internal slot
2665
+
the <codeclass="idl"><adata-link-type="idl" href="https://w3c.github.io/payment-request/#dom-paymentrequest" id="ref-for-dom-paymentrequest">PaymentRequest</a></code>’s <adata-link-type="dfn" href="https://www.w3.org/TR/payment-request/#dfn-state" id="ref-for-dfn-state">[[state]]</a> internal slot
0 commit comments