@@ -317,7 +317,7 @@ See also:
317
317
318
318
* [[LEAST-POWER]]
319
319
320
- <h3 id="high-level-low-level">Resolving tension between high level and low level APIs</h3>
320
+ <h3 id="high-level-low-level">Consider tradeoffs between high level and low level APIs</h3>
321
321
322
322
<!--
323
323
See "High level or low-level APIs?"
@@ -371,7 +371,7 @@ Naming APIs well makes it much easier for authors to use them correctly.
371
371
See the more detailed <a href="#naming-is-hard">Naming principles</a> section
372
372
for specific guidance on naming.
373
373
374
- <h3 id="consistency">Consistency </h3>
374
+ <h3 id="consistency">Be consistent </h3>
375
375
376
376
It is good practice to consider precedent in the design of your API
377
377
and to try to be consistent with it.
@@ -657,7 +657,7 @@ See also:
657
657
* [Security and privacy are essential] (https://www.w3.org/2001/tag/doc/ethical-web-principles/#privacy)
658
658
* [What data does this specification expose to an origin?] (https://www.w3.org/TR/security-privacy-questionnaire/#underlying-platform-data)
659
659
660
- <h3 id="require-user-activation">Powerful APIs should require user activation </h3>
660
+ <h3 id="require-user-activation">Require user activation for powerful APIs </h3>
661
661
662
662
Some powerful APIs can produce intrusive UI (eg. auto-playing audio),
663
663
expose user data (eg. interacting with the clipboard),
@@ -1139,7 +1139,7 @@ See also:
1139
1139
1140
1140
* [Computed Values Patterns] (https://wiki.csswg.org/spec/computed-values)
1141
1141
1142
- <h3 id="css-naming">Naming of CSS properties and values</h3>
1142
+ <h3 id="css-naming">Name CSS properties and values appropriately </h3>
1143
1143
1144
1144
The names of CSS properties are usually nouns,
1145
1145
and the names of their values are usually adjectives (although sometimes nouns).
@@ -1176,7 +1176,7 @@ default as a result of something like `display: flex` or `position: relative`.
1176
1176
1177
1177
<h2 id="js">JavaScript Language</h2>
1178
1178
1179
- <h3 id="js-only">Web APIs are for JavaScript </h3>
1179
+ <h3 id="js-only">Use JavaScript for Web APIs </h3>
1180
1180
1181
1181
When designing imperative APIs for the Web,
1182
1182
use JavaScript.
@@ -1519,7 +1519,7 @@ See also:
1519
1519
1520
1520
* [[#prefer-dict-to-bool]]
1521
1521
1522
- <h3 id="naming-optional-parameters">Naming optional arguments</h3>
1522
+ <h3 id="naming-optional-parameters">Name optional arguments appropriately </h3>
1523
1523
1524
1524
Name optional arguments to make the default behavior obvious
1525
1525
without being named negatively.
@@ -1726,7 +1726,7 @@ which might be expressed as a bitmask in another language,
1726
1726
use a dictionary object instead.
1727
1727
This object can be passed around as easily as a single bitmask value.
1728
1728
1729
- <h3 id="properties-vs-methods">Properties vs. Methods </h3>
1729
+ <h3 id="properties-vs-methods">Use properties and methods appropriately </h3>
1730
1730
1731
1731
Sometimes it is unclear whether to use a property or a method.
1732
1732
@@ -1812,7 +1812,7 @@ Similarly, add [=event handler IDL attributes=]
1812
1812
to {{WindowEventHandlers}} rather than {{Window}} .
1813
1813
</p>
1814
1814
1815
- <h3 id="events-are-for-notification">Events are for notification</h3>
1815
+ <h3 id="events-are-for-notification">Use events for notification</h3>
1816
1816
1817
1817
Events shouldn't be used to trigger changes,
1818
1818
only to deliver a notification that a change has already finished happening.
@@ -1970,14 +1970,14 @@ as it implies that it's possible to dispatch an event asynchronously.
1970
1970
All events are dispatched synchronously.
1971
1971
What is more often implied by "asynchronous event" is to defer firing an event.
1972
1972
1973
- <h3 id="state-and-subclassing">State and {{Event}} subclasses </h3>
1973
+ <h3 id="state-and-subclassing">Use plain {{Event}}s for state </h3>
1974
1974
1975
1975
Where possible, use a plain {{Event}} with a specified `type`,
1976
1976
and capture any state information in the {{Event/target}} object.
1977
1977
1978
1978
It's usually not necessary to create new subclasses of {{Event}} .
1979
1979
1980
- <h3 id="events-vs-observers">How to decide between Events and Observers</h3>
1980
+ <h3 id="events-vs-observers">Use Events and Observers appropriately </h3>
1981
1981
1982
1982
In general, use {{EventTarget}} and notification {{Event}} s,
1983
1983
rather than an Observer pattern,
@@ -2527,7 +2527,7 @@ or even restricting it further to only the current active tab.
2527
2527
Additionally, APIs should be designed so that the applications
2528
2528
can gracefully handle physical disruption, such as a device being unplugged.
2529
2529
2530
- <h3 id="wrapper-apis">Native APIs don't typically translate well to the web </h3>
2530
+ <h3 id="wrapper-apis">Adapt native APIs using web platform principles </h3>
2531
2531
2532
2532
When adapting native operating system APIs for the web,
2533
2533
make sure the new web APIs are designed with web platform principles in mind.
@@ -2562,7 +2562,7 @@ make sure the new web APIs are designed with web platform principles in mind.
2562
2562
2563
2563
<h2 id="other-considerations">Other API Design Considerations</h2>
2564
2564
2565
- <h3 id="polyfills">Polyfills </h3>
2565
+ <h3 id="polyfills">Enable polyfills for new features </h3>
2566
2566
2567
2567
Polyfills can be hugely beneficial
2568
2568
in helping to roll out new features to the web platform.
@@ -2589,7 +2589,7 @@ we still recommend designing the feature with DedicatedWorker support in mind,
2589
2589
in order to not add assumptions that will later make it unnecessarily hard to expose
2590
2590
these APIs to DedicatedWorker.
2591
2591
2592
- <h3 id="new-data-formats">New Data Formats </h3>
2592
+ <h3 id="new-data-formats">Add new data formats properly </h3>
2593
2593
2594
2594
Always define a corresponding MIME type and extend existing APIs to support this type
2595
2595
for any new data format.
@@ -2618,7 +2618,7 @@ due to security implications, and instead recommend enforcing strict MIME types
2618
2618
2619
2619
New MIME types should have a specification and should be registered with the Internet Assigned Numbers Authority (IANA).
2620
2620
2621
- <h3 id="new-http-header-syntax">New HTTP Headers</h3>
2621
+ <h3 id="new-http-header-syntax">Conform new HTTP Headers to standards </h3>
2622
2622
2623
2623
If you are defining a new HTTP header,
2624
2624
its syntax mustn't go against
@@ -2704,7 +2704,7 @@ which meant converting the names to camel-cased version.
2704
2704
One such example is the <a href="https://w3c.github.io/image-resource/">image resource</a> .
2705
2705
For this reason, if a key can clearly be expressed as a single word, that is recommended.
2706
2706
2707
- <h3 id="debuggability">Features should be developer-friendly</h3>
2707
+ <h3 id="debuggability">Ensure features are developer-friendly</h3>
2708
2708
2709
2709
Any new feature should be developer-friendly.
2710
2710
While it is hard to quantify friendliness, at least consider the following points.
@@ -2793,7 +2793,7 @@ or show different user interfaces for things like permission prompts.
2793
2793
Note: Implementers should file bugs against specifications
2794
2794
which don't give them clear enough information to write the implementation.
2795
2795
2796
- <h4 id="algorithms">Defining algorithms in specifications </h4>
2796
+ <h4 id="algorithms">Define algorithms clearly </h4>
2797
2797
2798
2798
Write algorithms in a way that is clear and concise.
2799
2799
@@ -2912,9 +2912,9 @@ to name this API less directly connected to its return type. [[FETCH]]
2912
2912
Names must adhere to the local language restrictions, for example CSS ident rules etc.
2913
2913
and *should* be in the [=ascii code point|ASCII range=] .
2914
2914
2915
- <h3 id="naming-consultation">Consultation </h4>
2915
+ <h3 id="naming-consultation">Consult others on naming </h4>
2916
2916
2917
- Please consult widely on names in your APIs.
2917
+ Consult widely on names in your APIs.
2918
2918
2919
2919
You may find good names or inspiration in surprising places.
2920
2920
- What are similar APIs named on other platforms,
@@ -2966,7 +2966,8 @@ If you need to refer to a generic persona,
2966
2966
such as an author or user,
2967
2967
use the generic pronoun "they", "their", etc.
2968
2968
For example, "A user may wish to adjust their preferences".
2969
- <h3 id="naming-future-proofing">Future-proofing</h4>
2969
+
2970
+ <h3 id="naming-future-proofing">Use future-proof names</h4>
2970
2971
2971
2972
Naming should be generic and future-proof whenever possible.
2972
2973
@@ -2993,7 +2994,7 @@ as they were to PS/2 and ADB keyboards back then. [[UIEVENTS]]
2993
2994
2994
2995
</div>
2995
2996
2996
- <h3 id="naming-consistency">Consistency </h4>
2997
+ <h3 id="naming-consistency">Name things consistently </h4>
2997
2998
Naming schemes should aim for consistency, to avoid confusion.
2998
2999
2999
3000
Sets of related names should agree with each other in:
@@ -3093,7 +3094,7 @@ examples that violate the above rules are {{XMLHttpRequest}} and
3093
3094
initialisms, even if they are repeated.
3094
3095
</div>
3095
3096
3096
- <h3 id="naming-unsafe">Warning about dangerous features</h4>
3097
+ <h3 id="naming-unsafe">Warn about dangerous features</h4>
3097
3098
3098
3099
Where possible, mark features that weaken
3099
3100
the guarantees provided to developers
@@ -3106,7 +3107,7 @@ CSP also provides features that weaken this guarantee,
3106
3107
such as the `unsafe-inline` keyword,
3107
3108
which reduces CSP's own protections by allowing inline scripts.
3108
3109
3109
- <h3 id="writing-resources">Other resources</h3 >
3110
+ <h2 id="writing-resources">Other resources</h2 >
3110
3111
3111
3112
Some useful advice on how to write specifications is available elsewhere:
3112
3113
* <a href="https://ln.hixie.ch/?start=1140242962&count=1">Writing
0 commit comments