Skip to content

Commit 6ced673

Browse files
Update the “Link type "serviceworker"” section
* Add new section “Declaring a "serviceworker" Link header” * Drop normative requirement to fire an error and abort if link[workertype] value is not a valid worker type. * Drop the partial interface IDL for the HTMLLinkElement interface (the definitions for the IDL attributes have already been merged directly into the HTMLLinkElement interface IDL definition in the HTML spec). Fixes #1073
1 parent b67c445 commit 6ced673

File tree

2 files changed

+127
-155
lines changed

2 files changed

+127
-155
lines changed

docs/index.bs

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
7474
text: ancestor origins list; for: Location; url: concept-location-ancestor-origins-list
7575
urlPrefix: syntax.html
7676
text: delay the load event; for: document; url: delay-the-load-event
77+
urlPrefix: semantics.html
78+
text: serviceworker; for: html; url: link-type-serviceworker
7779

7880
spec: fetch; urlPrefix: https://fetch.spec.whatwg.org/
7981
type: dfn
@@ -85,6 +87,7 @@ spec: rfc5988; urlPrefix: https://tools.ietf.org/html/rfc5988
8587
type: dfn
8688
text: context IRI; url: section-5.2
8789
text: target attribute; url: section-5.4
90+
text: target attributes; url: section-5.4
8891
text: target IRI; url: section-5.1
8992

9093
spec: rfc7230; urlPrefix: https://tools.ietf.org/html/rfc7230
@@ -1744,12 +1747,36 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
17441747
</section>
17451748

17461749
<section>
1747-
<h2 id="link-type-serviceworker">Link type "<code>serviceworker</code>"</h2>
1750+
<h2 id="link-type-serviceworker">Link type "`serviceworker`"</h2>
17481751

1749-
The <dfn id="dfn-link-type-serviceworker" lt="serviceworker link type"><code>serviceworker</code></dfn> keyword may be used with <{link}> elements. This keyword creates an <a>external resource link</a> (<dfn id="dfn-serviceworker-link">serviceworker link</dfn>) that is used to declare a [=/service worker registration=] and its [=service worker registration/scope url=].
1752+
A [=/service worker registration=] and its [=service worker registration/scope url=] are created by a <dfn id="dfn-serviceworker-link">serviceworker link</dfn>, which is declared using a <a href="#serviceworker-link-header">"serviceworker" `Link` header</a> or a <{link}> element whose <{link/rel}> attribute contains the keyword "<code>[=html/serviceworker=]</code>".
17501753

17511754
<section>
1752-
<h3 id="link-header-processing">Processing the <code>Link</code> header</h3>
1755+
<h3 id="serviceworker-link-header">Declaring a "serviceworker" <code>Link</code> header</h3>
1756+
1757+
A <a>serviceworker link</a> can be declared using a `Link` header</a> [[!RFC5988]] with "`serviceworker`" as the value of the "`rel`" parameter and a [=service worker/script url=] as the <a>target IRI</a>, and the following optional <a>target attributes</a>:
1758+
1759+
: `scope`
1760+
:: Value: A [=service worker registration/scope url=].
1761+
1762+
: `workertype`
1763+
:: Value: A [=job/worker type=].
1764+
1765+
: `updateviacache`
1766+
:: Value: An [=service worker registration/update via cache mode=].
1767+
1768+
The "`anchor`" parameter must not be specified.
1769+
1770+
<div class="example">
1771+
<pre class="highlight">
1772+
Link: &lt;sw.js&gt;; rel="serviceworker"; scope="/"; workertype="module"; updateviacache="all"
1773+
</pre>
1774+
</div>
1775+
1776+
</section>
1777+
1778+
<section>
1779+
<h3 id="link-header-processing">Processing a "serviceworker" <code>Link</code> header</h3>
17531780

17541781
When a user agent that supports [[!RFC5988]] processes a <code>Link</code> header that contains a <a>serviceworker link</a>, the user agent *should* run these steps:
17551782

@@ -1768,7 +1795,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
17681795
</section>
17691796

17701797
<section>
1771-
<h3 id="link-element-processing">Processing the <{link}> element</h3>
1798+
<h3 id="link-element-processing">Processing a "serviceworker" <{link}> element</h3>
17721799

17731800
When a <a>serviceworker link</a>'s <{link}> element is <a>inserted into a document</a>, or a <a>serviceworker link</a> is created on a <{link}> element that is already <a>in a document tree</a>, or the <{link/href}> or <{link/scope}> attributes of the <{link}> element of a <a>serviceworker link</a> is changed, the user agent *should* run these steps:
17741801

@@ -1778,8 +1805,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
17781805
1. Let |scriptURL| be the result of <a lt="URL parser">parsing</a> the <{link/href}> attribute with the <{link}> element's <a>node document</a>'s <a>document base URL</a>.
17791806
1. Let |scopeURL| be null.
17801807
1. If the <{link/scope}> attribute is present, set |scopeURL| to the result of <a lt="URL parser">parsing</a> the <{link/scope}> attribute with the <{link}> element's <a>node document</a>'s <a>document base URL</a>.
1781-
1. Let |workerType| be the <{link/workertype}> attribute, or "<code>classic</code>" if the <{link/workertype}> attribute is omitted.
1782-
1. If |workerType| is not a valid {{WorkerType}} value, <a>queue a task</a> to <a>fire an event</a> named <code>error</code> at the <{link}> element, and abort these steps.
1808+
1. Let |workerType| be the state of the <{link/workertype}> attribute.
17831809
1. Let |useCache| be true if the <{link}> element has a <{link/usecache}> attribute, otherwise false.
17841810
1. Let |promise| be a new <a>promise</a>.
17851811
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |promise|, |client|, |client|'s <a>creation URL</a>, |workerType|, and |useCache|.
@@ -1811,24 +1837,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
18111837
</pre>
18121838
</div>
18131839
</section>
1814-
1815-
<section>
1816-
<h3 id="link-element-interface-extensions">Link element interface extensions</h3>
1817-
1818-
<pre class="idl">
1819-
partial interface HTMLLinkElement {
1820-
[CEReactions] attribute USVString scope;
1821-
[CEReactions] attribute WorkerType workerType;
1822-
[CEReactions] attribute boolean useCache;
1823-
};
1824-
</pre>
1825-
1826-
The <dfn attribute for="HTMLLinkElement" id="link-scope-attribute">scope</dfn> IDL attribute must <a>reflect</a> the element's <dfn element-attr for="link">scope</dfn> content attribute.
1827-
1828-
The <dfn attribute for="HTMLLinkElement" id="link-workertype-attribute">workerType</dfn> IDL attribute must <a>reflect</a> the element's <dfn element-attr for="link">workertype</dfn> content attribute.
1829-
1830-
The <dfn attribute for="HTMLLinkElement" id="link-usecache-attribute">useCache</dfn> IDL attribute must <a>reflect</a> the element's <dfn element-attr for="link">usecache</dfn> content attribute.
1831-
</section>
18321840
</section>
18331841

18341842
<section>

0 commit comments

Comments
 (0)