From 59e75bb5eace7d378c5b52e47790cd8553bb66e7 Mon Sep 17 00:00:00 2001
From: Anne van Kesteren Parsing a URL is the process of taking a string and obtaining the URL record that
- it represents. While this process is defined in URL, the HTML standard defines a
- wrapper for convenience. URLParsing URLs
This wrapper is only useful when the character encoding for the URL parser has to - match that of the document or environment settings object for legacy reasons. When that is not the - case the URL parser can be used directly.
+Most new APIs are to use parse a URL. Older APIs and HTML elements + might have reason to use encoding-parse a URL. When a + custom base URL is needed or no base URL is desired, the URL parser can of course be + used directly as well.
-To parse a URL url, relative to a +
To parse a URL, given a string url, relative to a
Document
object or environment settings object environment,
run these steps. They return failure or a URL.
Let baseURL be environment's base
+ URL, if environment is a Document
object; otherwise
+ environment's API base URL.
Return the result of applying the URL parser to url, with + baseURL.
To encoding-parse a URL,
+ given a string url, relative to a Document
object or environment
+ settings object environment, run these steps. They return failure or a
+ URL.
Let encoding be environment's character encoding, if environment is a Document
object;
@@ -7082,18 +7097,19 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
Let baseURL be environment's base
URL, if environment is a Document
object; otherwise
- environment's API base URL otherwise.
Return the result of applying the URL parser to url, with baseURL and encoding.
To parse and serialize a URL url,
- relative to a Document
object or environment settings object
- environment, run these steps. They return failure or a string.
To encoding-parse-and-serialize a
+ URL, given a string url, relative to a Document
object or
+ environment settings object environment, run these steps. They return
+ failure or a string.
Let url be the result of parsing a URL +
Let url be the result of encoding-parsing a URL given url, relative to environment.
If url is failure, then return failure.
If the URL identified by the hyperlink is being shown to the user, or if any
data derived from that URL is affecting the display, then the href
attribute's value should be reparsed relative to the element's node document and the UI updated
- appropriately.
For example, the CSS :link
/:visited
pseudo-classes
@@ -7133,9 +7149,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
If the hyperlink has a ping
attribute and its
URL(s) are being shown to the user, then the ping
attribute's tokens should be reparsed relative to the element's node document and the UI updated
- appropriately.
q
, blockquote
, ins
, or
@@ -7144,8 +7160,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
If the URL identified by the cite
attribute is being
shown to the user, or if any data derived from that URL is affecting the display,
- then the cite
attribute's value should be reparsed relative to the element's node document and the UI updated
+ then the cite
attribute's value should be reparsed, relative to the element's node document and the UI updated
appropriately.
If contentAttributeValue is null, then return the empty string.
Let urlString be the result of parsing and serializing a URL - given contentAttributeValue, relative to element's node - document.
Let urlString be the result of encoding-parsing-and-serializing a + URL given contentAttributeValue, relative to element's + node document.
If urlString is not failure, then return urlString.
The base
element allows authors to specify the document base URL for
- the purposes of parsing URLs, and the name of the default
+ the purposes of parsing URLs, and the name of the default
navigable for the purposes of following hyperlinks. The element does not
represent any content beyond this information.
base
element isn't affected by itself.)
-
+
If any of the following are true:
@@ -14859,8 +14875,8 @@ interface HTMLBaseElement : HTMLElement { document's character encoding. (Thus, thebase
element isn't affected by other base
elements or
itself.)If urlRecord is failure, return url.
Let url be the result of parsing +
Let url be the result of encoding-parsing a URL given options's href, relative to options's base URL.
@@ -17020,8 +17036,8 @@ people expect to have work and what is necessary. code point, so that it and all subsequent code points are removed. -Parse: Set urlRecord to the result of parsing urlString relative to document.
Parse: Set urlRecord to the result of encoding-parsing a + URL given urlString, relative to document.
If urlRecord is failure, then return.
If element contributes a script-blocking style sheet, HTMLQuoteElement : HTMLElement {
If the If the cite
attribute is present, it must be a
valid URL potentially surrounded by spaces. To obtain the
- corresponding citation link, the value of the attribute must be parsed relative to the element's node document. User agents may
allow users to follow such citation links, but they are primarily intended for private use (e.g.,
by server-side scripts collecting statistics about a site's use of quotations), not for
@@ -22013,10 +22024,10 @@ gossip column, maybe!</q>.</p>
cite
attribute is present, it must be a valid
URL potentially surrounded by spaces. To obtain the corresponding citation
- link, the value of the attribute must be parsed relative to the
- element's node document. User agents may allow users to follow such citation
- links, but they are primarily intended for private use (e.g., by server-side scripts collecting
- statistics about a site's use of quotations), not for readers.
The q
element must not be used in place of quotation marks that do not represent
quotes; for example, it is inappropriate to use the q
element for marking up
@@ -24711,7 +24722,7 @@ document.body.appendChild(wbr);
If this element's href
content attribute is
absent, then return.
Let url be the result of parsing this +
Let url be the result of encoding-parsing a URL given this
element's href
content attribute's value, relative to
this element's node document.
If targetNavigable is null, then return.
Let urlString be the result of parsing and serializing a URL given
- subject's href
attribute value, relative to
- subject's node document.
Let urlString be the result of encoding-parsing-and-serializing a
+ URL given subject's href
attribute
+ value, relative to subject's node document.
If urlString is failure, then return.
Let urlString be the result of parsing and serializing a URL given
- subject's href
attribute value, relative to
- subject's node document.
Let urlString be the result of encoding-parsing-and-serializing a
+ URL given subject's href
attribute
+ value, relative to subject's node document.
If urlString is failure, then return.
If a hyperlink created by an a
or area
element has a
ping
attribute, and the user follows the hyperlink, and
the value of the element's href
attribute can be parsed, relative to the element's node document, without
- failure, then the user agent must take the ping
- attribute's value, split that string on ASCII
- whitespace, parse each resulting token, relative to the
- element's node document, and then run these steps for each resulting URL
- ping URL, ignoring when parsing returns failure:
ping
attribute's value, split that string on ASCII whitespace, parse each resulting token, relative to the element's node document, and
+ then run these steps for each resulting URL ping URL, ignoring when
+ parsing returns failure:
If ping URL's scheme is not an @@ -25507,9 +25519,9 @@ document.body.appendChild(wbr); data-x="">ping".
Let target URL be the result of parsing and serializing a URL given
- the element's href
attribute value, relative to the
- element's node document, and then:
Let target URL be the result of encoding-parsing-and-serializing a
+ URL given the element's href
attribute's value,
+ relative to the element's node document, and then:
Document
object
@@ -26126,7 +26138,7 @@ document.body.appendChild(wbr);
given a link
element el, are:
Let url be the result of parsing +
Let url be the result of encoding-parsing a URL given
el's href
attribute's value, relative to
el's node document.
error
at el, and return.Let url be the result of parsing +
Let url be the result of encoding-parsing a URL given
el's href
attribute's value, relative to
el's node document.
Let url be the result of parsing +
Let url be the result of encoding-parsing a URL given options's href, relative to options's base URL.
@@ -28046,8 +28058,8 @@ document.body.appendChild(wbr);If the cite
attribute is present, it must be a valid
URL potentially surrounded by spaces that explains the change. To obtain
- the corresponding citation link, the value of the attribute must be parsed relative to the element's node document. User agents may
+ the corresponding citation link, the value of the attribute must be parsed relative to the element's node document. User agents may
allow users to follow such citation links, but they are primarily intended for private use (e.g.,
by server-side scripts collecting statistics about a site's edits), not for readers.
Let urlString be the result of parsing and serializing a URL
- given selected source, relative to the element's node
+ Let urlString be the result of encoding-parsing-and-serializing a
+ URL given selected source, relative to the element's node
document.
Let urlString be the result of parsing and serializing a URL given - selected source, relative to the element's node document.
Let urlString be the result of encoding-parsing-and-serializing a + URL given selected source, relative to the element's node + document.
If urlString is failure, then:
@@ -31565,8 +31578,8 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ... -⌛ Let urlString be the result of parsing and serializing a
- URL given selected source, relative to the element's node
+ ⌛ Let urlString be the result of encoding-parsing-and-serializing
+ a URL given selected source, relative to the element's node
document. ⌛ If urlString is failure, then return.
Let maybeURL be the result of parsing that +
Let maybeURL be the result of encoding-parsing a URL given that attribute's value, relative to element's node document.
If maybeURL is not failure, then set url to @@ -33087,9 +33100,9 @@ interface HTMLIFrameElement : HTMLElement {
If, when the element is created, the srcdoc
attribute is not set, and the src
attribute is either also not set or set but its value cannot
- be parsed, the element's content navigable will
- remain at the initial about:blank
- Document
.
about:blank
Document
.
If the user navigates away from this page, the
If element has a Let url be the result of parsing the value
- of element's Let url be the result of encoding-parsing a URL given
+ element's If url is failure, then return.iframe
's content navigable's active
@@ -33618,8 +33631,8 @@ interface HTMLEmbedElement : HTMLElement {
src
attribute set, then:
-
src
attribute, relative to
+ src
attribute's value, relative to
element's node document.
Let url be the result of parsing the Let url be the result of encoding-parsing a URL given the If url is failure, then fire an
@@ -34399,7 +34412,7 @@ interface HTMLVideoElement : HTMLMediaElement
If the Let url be the result of parsing the Let url be the result of encoding-parsing a URL given the If value is not the empty string, then set trackURL to the result of
- parsing and serializing a URL given value, relative to the element's
- node document.data
attribute, relative to the element's node
+ data
attribute's value, relative to the element's node
document.poster
attribute's value is the empty string
or if the attribute is absent, then there is no poster frame; return.poster
attribute's value, relative to the element's node
document.
Set the element's track URL to trackURL if it is not failure; otherwise to the empty string.
⌛ Let urlRecord be the result of parsing the ⌛ Let urlRecord be the result of encoding-parsing a URL
+ given the src
attribute's value, relative
- to the media element's node document when the src
attribute's value, relative to the
+ media element's node document when the src
attribute was last changed.
⌛ Let urlRecord be the result of parsing candidate's src
- attribute's value, relative to candidate's node document when the
- src
attribute was last changed.
⌛ Let urlRecord be the result of encoding-parsing a URL
+ given candidate's src
attribute's value,
+ relative to candidate's node document when the src
attribute was last changed.
Indicates that the text track was enabled, but when the user agent attempted to obtain it, - this failed in some way (e.g., URL could not be parsed, network error, unknown text track format). Some or all of the cues are likely missing and will not be obtained.
Let url be the result of encoding-parsing a URL given the src
attribute's value, relative to the element's node
document.
Let parsed action be the result of parsing +
Let parsed action be the result of encoding-parsing a URL given action, relative to submitter's node document.
If parsed action is failure, then return.
Set el's from an external file to true.
Let url be the result of parsing +
Let url be the result of encoding-parsing a URL given src, relative to el's node document.
If url is failure, then queue an element task on the DOM
@@ -74004,9 +74017,9 @@ Demos:
The global identifier of an item is the value of
its element's The The value is the result of parsing and serializing a URL given the element's
- The value is the result of encoding-parsing-and-serializing a URL given the
+ element's The value is the result of parsing and serializing a URL given the element's
- The value is the result of encoding-parsing-and-serializing a URL given the
+ element's The value is the result of parsing and serializing a URL given the element's
- The value is the result of encoding-parsing-and-serializing a URL given the
+ element's itemid
attribute, if it has one, parsed relative to the node document of the element on
- which the attribute is specified. If the itemid
attribute is
- missing or if parsing it returns failure, it is said to have no global
+ data-x="encoding-parsing a URL">parsed relative to the node document of the
+ element on which the attribute is specified. If the itemid
+ attribute is missing or if parsing it returns failure, it is said to have no global
identifier.itemid
attribute must not be specified on elements that do
@@ -74264,8 +74277,8 @@ Demos:
img
, source
, track
, or video
element
src
attribute value, relative to the element's node
+ src
attribute's value, relative to the element's node
document, at the time the attribute is set, or the empty string if there is no such
attribute or the result is failure.a
, area
, or link
elementhref
attribute value, relative to the element's node
+ href
attribute's value, relative to the element's node
document, at the time the attribute is set, or the empty string if there is no such
attribute or the result is failure.object
elementdata
attribute value, relative to the element's node
+ data
attribute's value, relative to the element's node
document, at the time the attribute is set, or the empty string if there is no such
attribute or the result is failure.a
element with an href
attributehref
content attribute's value, relative
- to the element's node document.href
content attribute's value,
+ relative to the element's node document.img
element with a src
attributesrc
content attribute's value, relative to the
- element's node document.src
content attribute's value, relative to
+ the element's node document.
about:blank
.
If url is not the empty string, then set urlRecord to the result - of parsing url, relative to the entry + of encoding-parsing a URL given url, relative to the entry settings object.
If urlRecord is failure, then throw a " If url is not the empty string, then: Let urlRecord be the result of parsing
+ Let urlRecord be the result of encoding-parsing a URL
url, relative to the entry settings object. If urlRecord is failure, then throw a
@@ -88591,7 +88604,7 @@ interface Location { // but see also parsingSyntaxError
"
@@ -87143,7 +87156,7 @@ dictionary WindowPostMessageOptions : StructuredSeri
-
the given
+
Let url be the result of encoding-parsing a URL given the given value, relative to the entry settings object.
If url is failure, then throw a "SyntaxError
"
@@ -88996,7 +89009,7 @@ interface Location { // but see also origin
SecurityError
" DOMException
.
- Let urlRecord be the result of parsing +
Let urlRecord be the result of encoding-parsing a URL given url, relative to the entry settings object.
If urlRecord is failure, then throw a " Let urlRecord be the result of encoding-parsing a URL given
url, relative to the entry settings object. If urlRecord is failure, then throw a " If url is not null or the empty string, then: Set newURL to the result of parsing
+ Set newURL to the result of encoding-parsing a URL given
url, relative to the relevant settings object of
history.SyntaxError
"
@@ -89013,7 +89026,7 @@ interface Location { // but see also parsing
+ SyntaxError
"
@@ -89451,7 +89464,7 @@ interface History {
-
Let urlRecord be the result of parsing +
Let urlRecord be the result of encoding-parsing a URL given url, relative to this's relevant settings object.
If urlRecord is failure, then return an
For each string of input: Let parsed be the result of parsing
+ Let parsed be the result of encoding-parsing a URL given
string, relative to the current settings object. If parsed is failure, then return a promise rejected with a
@@ -110602,7 +110615,7 @@ interface Navigator {
If url does not contain " Let urlRecord be the result of parsing
+ Let urlRecord be the result of encoding-parsing a URL given
url, relative to environment. Let outside settings be the current settings object. Let worker URL be the result of parsing
+ Let worker URL be the result of encoding-parsing a URL given
scriptURL, relative to outside settings. Any same-origin URL (including Let outside settings be the current settings object. Let urlRecord be the result of parsing
+ Let urlRecord be the result of encoding-parsing a URL given
scriptURL, relative to outside settings. Any same-origin URL (including For each url of urls: Let urlRecord be the result of parsing
+ Let urlRecord be the result of encoding-parsing a URL given
url, relative to settings object. If urlRecord is failure, then throw a " Let outsideSettings be the relevant settings object of
this. Let moduleURLRecord be the result of parsing
+ Let moduleURLRecord be the result of encoding-parsing a URL given
moduleURL, relative to outsideSettings. If moduleURLRecord is failure, then return a promise rejected with
@@ -128792,11 +128805,12 @@ html, body { display: block; } When a When a When a When a User agents may allow users to navigate navigables to the URLs indicated by
- the
-
to the URLs indicated by the %s
", then throw a
"SyntaxError
" DOMException
.SharedWorker : EventTarget {
SharedWorker : EventTarget {
-
SyntaxError
"
@@ -116447,7 +116460,7 @@ dictionary WorkletOptions {
body
element has a background
- attribute set to a non-empty value, the new value is expected to be parsed and serialized relative to the element's node
- document, and if that does not return failure, the user agent is expected to treat the
- attribute as a presentational hint setting the
- element's 'background-image' property to the return value.body
element has a bgcolor
attribute set, the new value is expected to be parsed using the rules for parsing a legacy
@@ -129638,11 +129652,11 @@ table {
table
, thead
, tbody
, tfoot
,
tr
, td
, or th
element has a background
attribute set to a non-empty value, the new value is
- expected to be parsed and serialized relative
- to the element's node document, and if that does not return failure, the user agent
- is expected to treat the attribute as a presentational
- hint setting the element's 'background-image' property to the return
- value.table
, thead
, tbody
, tfoot
,
tr
, td
, or th
element has a bgcolor
@@ -131425,9 +131439,9 @@ progress { appearance: auto; }
as part of such auditing.cite
attributes on q
, blockquote
,
- ins
, and del
elements.cite
attributes on q
,
+ blockquote
, ins
, and del
elements.
User agents may surface hyperlinks created by link
elements in their user interface, as discussed