Skip to content

Commit 84e9c25

Browse files
committed
deploy: b2c1996
1 parent 1b258c3 commit 84e9c25

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

index.html

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<meta content="Bikeshed version 742f3d674, updated Mon Nov 4 14:56:54 2024 -0800" name="generator">
99
<link href="https://www.w3.org/TR/design-principles/" rel="canonical">
1010
<link href="https://www.w3.org/2008/site/images/favicon.ico" rel="icon">
11-
<meta content="d0137b55cb7ea3011b346f5fd94f51479310017f" name="revision">
11+
<meta content="b2c19969a41af097ac2233009f0b2af69ea6aeed" name="revision">
1212
<meta content="dark light" name="color-scheme">
1313
<link href="https://www.w3.org/StyleSheets/TR/2021/dark.css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css">
1414
<style>
@@ -2074,8 +2074,6 @@ <h3 class="heading settled" data-level="6.4" id="prefer-dictionaries"><span clas
20742074
<ul>
20752075
<li data-md>
20762076
<p><a href="https://ariya.io/2011/08/hall-of-api-shame-boolean-trap">Hall of API Shame: Boolean Trap</a>.</p>
2077-
<li data-md>
2078-
<p><a href="https://lists.w3.org/Archives/Public/public-script-coord/2013OctDec/0302.html">APIs that have boolean arguments defaulting to true</a></p>
20792077
<li data-md>
20802078
<p><a href="#optional-parameters">§ 6.5 Make method arguments optional if possible</a></p>
20812079
<li data-md>
@@ -2087,14 +2085,11 @@ <h3 class="heading settled" data-level="6.5" id="optional-parameters"><span clas
20872085
<div class="example" id="example-6724ca08"><a class="self-link" href="#example-6724ca08"></a> <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener" id="ref-for-dom-eventtarget-addeventlistener">addEventListener()</a></code> takes an optional boolean <code>useCapture</code> argument.
20882086
This defaults to <code>false</code>, meaning that
20892087
the event should be dispatched to the listener in the bubbling phase by default. </div>
2090-
<p class="note" role="note"><span class="marker">Note:</span> Exceptions have been made for legacy interoperability reasons
2091-
(such as <code class="idl"><a data-link-type="idl" href="https://xhr.spec.whatwg.org/#xmlhttprequest" id="ref-for-xmlhttprequest">XMLHttpRequest</a></code>),
2092-
but this should be considered a design mistake rather than recommended practice.</p>
2093-
<p>The API must be designed so that if an argument is left out,
2094-
the default value used is the same as
2095-
converting <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-undefined" id="ref-for-idl-undefined">undefined</a></code> to the type of the argument.
2096-
For example, if a boolean argument isn’t set,
2097-
it must default to false.</p>
2088+
<p>For boolean arguments,
2089+
a default value of <code>false</code> is strongly preferred.</p>
2090+
<div class="example" id="example-6a0c0a03"><a class="self-link" href="#example-6a0c0a03"></a> The third, optional argument to <code class="idl"><a data-link-type="idl" href="https://xhr.spec.whatwg.org/#xmlhttprequest" id="ref-for-xmlhttprequest">XMLHttpRequest</a></code> defaults to <code>true</code> as an exception to this rule.
2091+
This is for legacy interoperability reasons,
2092+
not as an example of good design. </div>
20982093
<p>When deciding between different list data types for your API,
20992094
unless otherwise required, use the following list types:</p>
21002095
<ul>
@@ -2109,6 +2104,8 @@ <h3 class="heading settled" data-level="6.5" id="optional-parameters"><span clas
21092104
<ul>
21102105
<li data-md>
21112106
<p><a href="#prefer-dictionaries">§ 6.4 Accept optional and/or primitive arguments through dictionaries</a></p>
2107+
<li data-md>
2108+
<p><a href="https://lists.w3.org/Archives/Public/public-script-coord/2013OctDec/0302.html">APIs that have boolean arguments defaulting to true</a></p>
21122109
</ul>
21132110
<h3 class="heading settled" data-level="6.6" id="naming-optional-parameters"><span class="secno">6.6. </span><span class="content">Name optional arguments appropriately</span><a class="self-link" href="#naming-optional-parameters"></a></h3>
21142111
<p>Name optional arguments to make the default behavior obvious
@@ -2333,7 +2330,7 @@ <h3 class="heading settled" data-level="6.15" id="void-functions"><span class="s
23332330
is to cause side effects
23342331
and not to compute a value,
23352332
the function should be specified
2336-
to return <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-undefined" id="ref-for-idl-undefined">undefined</a></code>.</p>
2333+
to return <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-undefined" id="ref-for-idl-undefined">undefined</a></code>.</p>
23372334
<p>Sites are unlikely
23382335
to come to depend on
23392336
such a return value,
@@ -2345,7 +2342,7 @@ <h3 class="heading settled" data-level="6.15" id="void-functions"><span class="s
23452342
<div class="example" id="example-5e29a724">
23462343
<a class="self-link" href="#example-5e29a724"></a>
23472344
<p><code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/media.html#htmlmediaelement" id="ref-for-htmlmediaelement">HTMLMediaElement</a></code>’s <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/media.html#dom-media-play" id="ref-for-dom-media-play">play()</a></code> method
2348-
was originally defined to return <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-undefined" id="ref-for-idl-undefined">undefined</a></code>,
2345+
was originally defined to return <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-undefined" id="ref-for-idl-undefined">undefined</a></code>,
23492346
since its purpose was
23502347
to change the state
23512348
of the media element.</p>
@@ -2354,7 +2351,7 @@ <h3 class="heading settled" data-level="6.15" id="void-functions"><span class="s
23542351
in a number of ways,
23552352
so <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/media.html#dom-media-play" id="ref-for-dom-media-play①">play()</a></code> was <a href="https://github.com/whatwg/html/issues/505">changed</a> to return a <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-promise" id="ref-for-idl-promise">Promise</a></code>.
23562353
If the <abbr>API</abbr> had originally been defined
2357-
to return something other than <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-undefined" id="ref-for-idl-undefined">undefined</a></code> (for example,
2354+
to return something other than <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-undefined" id="ref-for-idl-undefined">undefined</a></code> (for example,
23582355
if it had been defined
23592356
to return the media element,
23602357
a popular pattern
@@ -4703,7 +4700,7 @@ <h2 class="no-num no-ref heading settled" id="property-index"><span class="conte
47034700
"5def70a6": {"dfnID":"5def70a6","dfnText":"querySelectorAll(selectors)","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-parentnode-queryselectorall"}],"title":"Static objects"}],"url":"https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall"},
47044701
"5eafebb0": {"dfnID":"5eafebb0","dfnText":"sequence type","external":true,"refSections":[{"refs":[{"id":"ref-for-sequence-type"},{"id":"ref-for-sequence-type\u2460"}],"title":"6.5. Make method arguments optional if possible"},{"refs":[{"id":"ref-for-sequence-type\u2461"}],"title":"8.2. Represent strings appropriately"}],"url":"https://webidl.spec.whatwg.org/#sequence-type"},
47054702
"5f753d3e": {"dfnID":"5f753d3e","dfnText":"action","external":true,"refSections":[{"refs":[{"id":"ref-for-attr-fs-action"}],"title":"3.6. Name URL-containing attributes based on their primary purpose"}],"url":"https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-action"},
4706-
"5f90bbfb": {"dfnID":"5f90bbfb","dfnText":"undefined","external":true,"refSections":[{"refs":[{"id":"ref-for-idl-undefined"}],"title":"6.5. Make method arguments optional if possible"},{"refs":[{"id":"ref-for-idl-undefined\u2460"},{"id":"ref-for-idl-undefined\u2461"},{"id":"ref-for-idl-undefined\u2462"}],"title":"6.15. Return undefined from side-effect-causing functions"}],"url":"https://webidl.spec.whatwg.org/#idl-undefined"},
4703+
"5f90bbfb": {"dfnID":"5f90bbfb","dfnText":"undefined","external":true,"refSections":[{"refs":[{"id":"ref-for-idl-undefined"},{"id":"ref-for-idl-undefined\u2460"},{"id":"ref-for-idl-undefined\u2461"}],"title":"6.15. Return undefined from side-effect-causing functions"}],"url":"https://webidl.spec.whatwg.org/#idl-undefined"},
47074704
"5f95ccda": {"dfnID":"5f95ccda","dfnText":"Error","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-error-objects"}],"title":"8.5. Use Error or DOMException for errors"}],"url":"https://tc39.github.io/ecma262/#sec-error-objects"},
47084705
"5fd23811": {"dfnID":"5fd23811","dfnText":"fire an event","external":true,"refSections":[{"refs":[{"id":"ref-for-concept-event-fire"}],"title":"7.6. Guard against potential recursion"}],"url":"https://dom.spec.whatwg.org/#concept-event-fire"},
47094706
"613edb27": {"dfnID":"613edb27","dfnText":"play()","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-media-play"},{"id":"ref-for-dom-media-play\u2460"}],"title":"6.15. Return undefined from side-effect-causing functions"}],"url":"https://html.spec.whatwg.org/multipage/media.html#dom-media-play"},

0 commit comments

Comments
 (0)