Skip to content

Commit a96703c

Browse files
LeaVerourhiaro
andauthored
Clarify that different functionality should NOT use the same attributes (#345)
* Clarify that different functionality should NOT use the same attributes * Update index.bs Co-authored-by: Amy Guy <[email protected]> Co-authored-by: Amy Guy <[email protected]>
1 parent 07386d3 commit a96703c

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

index.bs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ See also:
631631

632632
After a user navigated away from a document,
633633
the document might be cached in a non-[=Document/fully active=] state,
634-
and might be reused when the user navigates back to the entry holding the document, which makes navigation fast for users.
635-
In browsers, this is known as the back/forward cache, or "<abbr title="back/forward cache">BFCache</abbr>" for short.
634+
and might be reused when the user navigates back to the entry holding the document, which makes navigation fast for users.
635+
In browsers, this is known as the back/forward cache, or "<abbr title="back/forward cache">BFCache</abbr>" for short.
636636
In the past, many APIs have missed specifying support for non-[=Document/fully active=] documents,
637637
making them hard to support in various user agents to cache pages in the BFCache, effectively making the user experience of navigating back and forth less optimal.
638638

@@ -660,7 +660,7 @@ as it is written only for handling non-[=Document/fully active=] documents.
660660
In many cases,
661661
anything that happens while the document is not [=Document/fully active=]
662662
should be treated as if it never happened.
663-
If it makes more sense to "update" a document to ensure it does not hold stale information
663+
If it makes more sense to "update" a document to ensure it does not hold stale information
664664
after it becomes [=Document/fully active=] again, consider the [[#listen-fully-active]] pattern below.
665665
<div class="example">
666666
APIs that periodically send information updates,
@@ -677,10 +677,10 @@ When a document goes from [=Document/fully active=] to non-[=Document/fully acti
677677
it should be treated similarly to the way discarded documents are treated.
678678
The document must not retain exclusive access to shared resources
679679
and must ensure that no new requests are issued
680-
and that connections that allow for new incoming requests are terminated.
680+
and that connections that allow for new incoming requests are terminated.
681681
When a document goes from non-[=Document/fully active=] to [=Document/fully active=] again,
682682
it can restore connections if appropriate.
683-
683+
684684
While web authors can manually do cleanup (e.g. release the resources, sever connections)
685685
from within the {{pagehide}} event and restore them from the {{pageshow}} event themselves,
686686
doing this automatically from the API design allows the document to be kept alive after navigation by default,
@@ -707,7 +707,7 @@ If there is an API to signal to the page that this has happened,
707707
it may be acceptable but beware that if the only time this happens is with BFCache,
708708
then it's likely many pages are not prepared for it. If it is not possible to support BFCache,
709709
follow the [[#discard]] pattern described below.
710-
710+
711711
Additionally, when a document becomes [=Document/fully active=] again,
712712
it can be useful to update it with the current state of the world,
713713
if anything has changed while it is in the non-[=Document/fully active=] state.
@@ -809,7 +809,7 @@ and doing cleanup as necessary (see above).
809809

810810
This section details design principles for features which are exposed via HTML.
811811

812-
<h3 id="attribute-reuse">Re-use attribute names for similar functionality</h3>
812+
<h3 id="attribute-reuse">Re-use attribute names (only) for similar functionality</h3>
813813

814814
If you are adding a feature that is specified through an HTML attribute,
815815
check if there is an existing attribute name on another element
@@ -848,6 +848,18 @@ try to keep its syntax as close as possible to the syntax of the existing attrib
848848
and the other one a selector, that would be an antipattern.
849849
</div>
850850

851+
The inverse also applies:
852+
do **not** re-use an existing attribute name if
853+
the functionality you are adding is **not** similar to that of the existing attribute.
854+
855+
<div class="example">
856+
The `type` attribute is used on the <{input}> and <{button}> elements
857+
to further specialize the element type,
858+
whereas on every other element (e.g. <{link}>, <{script}>, <{style}>)
859+
it specifies MIME type.
860+
This is an antipattern; one of these groups of attributes should have had a different name.
861+
</div>
862+
851863
<h2 id="css">Cascading Style Sheets (CSS)</h2>
852864

853865
This section details design principles for features which are exposed via CSS.

0 commit comments

Comments
 (0)