Skip to content

Commit ee567cc

Browse files
committed
Revamp base URL change processing
This removes the dependency on two concepts supposedly defined in DOM, that have not existed for many years. Instead, we have HTML directly call into the new "respond to base URL changes" steps, when mutations happen to a Document that would cause the base URL to change. Also reorganizes some of the base URL stuff to stick together, instead of being mixed between "Dynamic changes to base URLs" and "Terminology". Closes whatwg/dom#61.
1 parent 8035a25 commit ee567cc

File tree

1 file changed

+69
-83
lines changed

1 file changed

+69
-83
lines changed

source

Lines changed: 69 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,7 +3328,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
33283328
<dfn data-x="concept-node-clone-parent" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-parent"><var>parent</var></dfn>, and
33293329
<dfn data-x="concept-node-clone-fallbackRegistry" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-fallbackregistry"><var>fallbackRegistry</var></dfn>, and the concept of
33303330
<dfn data-x="concept-node-clone-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-clone-ext">cloning steps</dfn></li>
3331-
<li>The concept of <dfn>base URL change steps</dfn> and the definition of what happens when an element is <dfn>affected by a base URL change</dfn></li>
33323331
<li>The concept of an element's <dfn data-x="concept-id" data-x-href="https://dom.spec.whatwg.org/#concept-id">unique identifier (ID)</dfn></li>
33333332
<li>The concept of an element's <dfn data-x="concept-class" data-x-href="https://dom.spec.whatwg.org/#concept-class">classes</dfn></li>
33343333
<li>The term <dfn data-x="concept-supported-tokens" data-x-href="https://dom.spec.whatwg.org/#concept-supported-tokens">supported tokens</dfn></li>
@@ -7216,6 +7215,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
72167215
data-x="strip leading and trailing ASCII whitespace">stripping leading and trailing ASCII
72177216
whitespace</span> from it, it is a <span>valid non-empty URL</span>.</p>
72187217

7218+
<hr>
7219+
72197220
<p>This specification defines the URL <dfn><code>about:legacy-compat</code></dfn> as a reserved,
72207221
though unresolvable, <code data-x="about protocol">about:</code> URL, for use in <span
72217222
data-x="syntax-doctype">DOCTYPE</span>s in <span>HTML documents</span> when needed for
@@ -7231,46 +7232,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
72317232
document"><code>iframe</code> <code data-x="attr-iframe-srcdoc">srcdoc</code> documents</span>.
72327233
<ref>ABOUT</ref></p>
72337234

7234-
<p>The <dfn>fallback base URL</dfn> of a <code>Document</code> object <var>document</var> is the
7235-
<span>URL record</span> obtained by running these steps:</p>
7236-
7237-
<ol>
7238-
<li>
7239-
<p>If <var>document</var> is <span data-x="an iframe srcdoc document">an <code>iframe</code>
7240-
<code data-x="attr-iframe-srcdoc">srcdoc</code> document</span>, then:</p>
7241-
7242-
<ol>
7243-
<li><p><span>Assert</span>: <var>document</var>'s <span
7244-
data-x="concept-document-about-base-url">about base URL</span> is non-null.</p></li>
7245-
7246-
<li><p>Return <var>document</var>'s <span data-x="concept-document-about-base-url">about base
7247-
URL</span>.</p></li>
7248-
</ol>
7249-
</li>
7250-
7251-
<li><p>If <var>document</var>'s <span data-x="concept-document-url">URL</span> <span>matches
7252-
<code>about:blank</code></span> and <var>document</var>'s <span
7253-
data-x="concept-document-about-base-url">about base URL</span> is non-null, then return
7254-
<var>document</var>'s <span data-x="concept-document-about-base-url">about base URL</span>.</p></li>
7255-
7256-
<!-- https://www.hixie.ch/tests/adhoc/dom/level0/history/pushState/001/ -->
7257-
7258-
<li><p>Return <var>document</var>'s <span data-x="concept-document-url">URL</span>.</p></li>
7259-
</ol>
7260-
7261-
<p>The <dfn export>document base URL</dfn> of a <code>Document</code> object is the
7262-
<span>URL record</span> obtained by running these steps:</p>
7263-
7264-
<ol>
7265-
<li><p>If there is no <code>base</code> element that has an <code
7266-
data-x="attr-base-href">href</code> attribute in the <code>Document</code>, then return the
7267-
<code>Document</code>'s <span>fallback base URL</span>.</p></li>
7268-
7269-
<li><p>Otherwise, return the <span>frozen base URL</span> of the first <code>base</code> element
7270-
in the <code>Document</code> that has an <code data-x="attr-base-href">href</code> attribute, in
7271-
<span>tree order</span>.</p></li>
7272-
</ol>
7273-
72747235
<hr>
72757236

72767237
<p>A <span>URL</span> <dfn>matches <code>about:blank</code></dfn> if its <span
@@ -7378,58 +7339,82 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
73787339

73797340
<div w-nodev>
73807341

7381-
<h4>Dynamic changes to base URLs</h4>
7342+
<h4>Document base URLs</h4>
73827343

7383-
<p>When a document's <span>document base URL</span> changes, all elements in that document are
7384-
<span>affected by a base URL change</span>.</p>
7344+
<p>The <dfn export>document base URL</dfn> of a <code>Document</code> <var>document</var> is the
7345+
<span>URL record</span> obtained by running these steps:</p>
73857346

7386-
<p>The following are <span>base URL change steps</span>, which run when an element is
7387-
<span>affected by a base URL change</span> (as defined by <cite>DOM</cite>):</p>
7347+
<ol>
7348+
<li><p>If there is no <code>base</code> element that has an <code
7349+
data-x="attr-base-href">href</code> attribute in <var>document</var>, then return
7350+
<var>document</var>'s <span>fallback base URL</span>.</p></li>
73887351

7389-
<dl class="switch">
7352+
<li><p>Otherwise, return the <span>frozen base URL</span> of the first <code>base</code> element
7353+
in <var>document</var> that has an <code data-x="attr-base-href">href</code> attribute, in
7354+
<span>tree order</span>.</p></li>
7355+
</ol>
73907356

7391-
<dt>If the element creates a <span>hyperlink</span></dt>
7357+
<p>The <dfn>fallback base URL</dfn> of a <code>Document</code> object <var>document</var> is the
7358+
<span>URL record</span> obtained by running these steps:</p>
73927359

7393-
<dd>
7394-
<p>If the <span>URL</span> identified by the hyperlink is being shown to the user, or if any
7395-
data derived from that <span>URL</span> is affecting the display, then the <code
7396-
data-x="attr-hyperlink-href">href</code> attribute's value should be <span
7397-
data-x="encoding-parsing a URL">reparsed</span>, relative to the element's <span>node
7398-
document</span> and the UI updated appropriately.</p>
7360+
<ol>
7361+
<li>
7362+
<p>If <var>document</var> is <span data-x="an iframe srcdoc document">an <code>iframe</code>
7363+
<code data-x="attr-iframe-srcdoc">srcdoc</code> document</span>, then:</p>
73997364

7400-
<p class="example">For example, the CSS <code data-x="selector-link">:link</code>/<code
7401-
data-x="selector-visited">:visited</code> <span data-x="pseudo-class">pseudo-classes</span>
7402-
might have been affected.</p>
7365+
<ol>
7366+
<li><p><span>Assert</span>: <var>document</var>'s <span
7367+
data-x="concept-document-about-base-url">about base URL</span> is non-null.</p></li>
74037368

7404-
<p>If the hyperlink has a <code data-x="attr-hyperlink-ping">ping</code> attribute and its
7405-
<span data-x="URL">URL(s)</span> are being shown to the user, then the <code
7406-
data-x="attr-hyperlink-ping">ping</code> attribute's tokens should be <span
7407-
data-x="encoding-parsing a URL">reparsed</span>, relative to the element's <span>node
7408-
document</span> and the UI updated appropriately.</p>
7409-
</dd>
7369+
<li><p>Return <var>document</var>'s <span data-x="concept-document-about-base-url">about base
7370+
URL</span>.</p></li>
7371+
</ol>
7372+
</li>
74107373

7411-
<dt>If the element is a <code>q</code>, <code>blockquote</code>, <code>ins</code>, or
7412-
<code>del</code> element with a <code data-x="">cite</code> attribute</dt>
7374+
<li><p>If <var>document</var>'s <span data-x="concept-document-url">URL</span> <span>matches
7375+
<code>about:blank</code></span> and <var>document</var>'s <span
7376+
data-x="concept-document-about-base-url">about base URL</span> is non-null, then return
7377+
<var>document</var>'s <span data-x="concept-document-about-base-url">about base
7378+
URL</span>.</p></li>
74137379

7414-
<dd>
7415-
<p>If the <span>URL</span> identified by the <code data-x="">cite</code> attribute is being
7416-
shown to the user, or if any data derived from that <span>URL</span> is affecting the display,
7417-
then the <code data-x="">cite</code> attribute's value should be <span data-x="encoding-parsing
7418-
a URL">reparsed</span>, relative to the element's <span>node document</span> and the UI updated
7419-
appropriately.</p>
7420-
</dd>
7380+
<!-- https://www.hixie.ch/tests/adhoc/dom/level0/history/pushState/001/ -->
74217381

7422-
<dt>Otherwise</dt>
7382+
<li><p>Return <var>document</var>'s <span data-x="concept-document-url">URL</span>.</p></li>
7383+
</ol>
74237384

7424-
<dd>
7425-
<p>The element is not directly affected.</p>
7385+
<hr>
74267386

7427-
<p class="example">For instance, changing the base URL doesn't affect the image displayed by
7428-
<code>img</code> elements, although subsequent accesses of the <code
7429-
data-x="dom-img-src">src</code> IDL attribute from script will return a new <span>absolute
7430-
URL</span> that might no longer correspond to the image being shown.</p>
7431-
</dd>
7432-
</dl>
7387+
<p>To <dfn>set the URL</dfn> for a <code>Document</code> <var>document</var> to a <span>URL
7388+
record</span> <var>url</var>:</p>
7389+
7390+
<ol>
7391+
<li><p>Set <var>document</var>'s <span data-x="concept-document-url">URL</span> to
7392+
<var>url</var>.</p></li>
7393+
7394+
<li><p><span>Respond to base URL changes</span> given <var>document</var>.</p></li>
7395+
</ol>
7396+
7397+
<p id="dynamic-changes-to-base-urls">To <dfn>respond to base URL changes</dfn> for a
7398+
<code>Document</code> <var>document</var>:</p>
7399+
7400+
<ol>
7401+
<li><p>The user agent should update any user interface elements which are displaying affected
7402+
URLs, or data derived from such URLs, to the user. Examples of such user interface elements would
7403+
be a status bar that displays a <span>hyperlink</span>'s <span
7404+
data-x="concept-hyperlink-url">url</span>, or some user interface which displays the URL
7405+
specified by a <code>q</code>, <code>blockquote</code>, <code>ins</code>, or <code>del</code>
7406+
element's <code data-x="">cite</code> attribute.</p></li>
7407+
7408+
<li><p>Ensure that the CSS <code data-x="selector-link">:link</code>/<code
7409+
data-x="selector-visited">:visited</code>/etc. <span data-x="pseudo-class">pseudo-classes</span>
7410+
are updated appropriately.</p></li>
7411+
</ol>
7412+
7413+
<p class="example" id="example-base-url-change-img-unaffected">This means that changing the base
7414+
URL doesn't affect, for example, the image displayed by <code>img</code> elements. Thus,
7415+
subsequent accesses of the <code data-x="dom-img-src">src</code> IDL attribute from script will
7416+
return a new <span>absolute URL</span> that might no longer correspond to the image being
7417+
shown.</p>
74337418

74347419
</div>
74357420

@@ -15279,6 +15264,8 @@ interface <dfn interface>HTMLBaseElement</dfn> : <span>HTMLElement</span> {
1527915264
</li>
1528015265

1528115266
<li><p>Set <var>element</var>'s <span>frozen base URL</span> to <var>urlRecord</var>.</p></li>
15267+
15268+
<li><p><span>Respond to base URL changes</span> given <var>document</var>.</p></li>
1528215269
</ol>
1528315270

1528415271
<p>The <dfn attribute for="HTMLBaseElement"><code data-x="dom-base-href">href</code></dfn> IDL
@@ -103093,8 +103080,7 @@ location.href = '#foo';</code></pre>
103093103080
state</span> given <var>document</var> and <var>newEntry</var>.</p></li>
103094103081

103095103082
<li>
103096-
<p>Set <var>document</var>'s <span data-x="concept-document-url">URL</span> to
103097-
<var>newURL</var>.</p>
103083+
<p><span>Set the URL</span> given <var>document</var> to <var>newURL</var>.</p>
103098103084

103099103085
<p class="note">Since this is neither a <span data-x="navigate">navigation</span> nor a <span
103100103086
data-x="traverse the history by a delta">history traversal</span>, it does not cause a <code

0 commit comments

Comments
 (0)