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
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]>
Copy file name to clipboardExpand all lines: index.bs
+19-7Lines changed: 19 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -631,8 +631,8 @@ See also:
631
631
632
632
After a user navigated away from a document,
633
633
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.
636
636
In the past, many APIs have missed specifying support for non-[=Document/fully active=] documents,
637
637
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.
638
638
@@ -660,7 +660,7 @@ as it is written only for handling non-[=Document/fully active=] documents.
660
660
In many cases,
661
661
anything that happens while the document is not [=Document/fully active=]
662
662
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
664
664
after it becomes [=Document/fully active=] again, consider the [[#listen-fully-active]] pattern below.
665
665
<div class="example">
666
666
APIs that periodically send information updates,
@@ -677,10 +677,10 @@ When a document goes from [=Document/fully active=] to non-[=Document/fully acti
677
677
it should be treated similarly to the way discarded documents are treated.
678
678
The document must not retain exclusive access to shared resources
679
679
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.
681
681
When a document goes from non-[=Document/fully active=] to [=Document/fully active=] again,
682
682
it can restore connections if appropriate.
683
-
683
+
684
684
While web authors can manually do cleanup (e.g. release the resources, sever connections)
685
685
from within the {{pagehide}} event and restore them from the {{pageshow}} event themselves,
686
686
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,
707
707
it may be acceptable but beware that if the only time this happens is with BFCache,
708
708
then it's likely many pages are not prepared for it. If it is not possible to support BFCache,
709
709
follow the [[#discard]] pattern described below.
710
-
710
+
711
711
Additionally, when a document becomes [=Document/fully active=] again,
712
712
it can be useful to update it with the current state of the world,
713
713
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).
809
809
810
810
This section details design principles for features which are exposed via HTML.
811
811
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>
813
813
814
814
If you are adding a feature that is specified through an HTML attribute,
815
815
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
848
848
and the other one a selector, that would be an antipattern.
849
849
</div>
850
850
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
+
851
863
<h2 id="css">Cascading Style Sheets (CSS)</h2>
852
864
853
865
This section details design principles for features which are exposed via CSS.
0 commit comments