Skip to content

Commit fad4ecc

Browse files
committed
Expose a URLHost class to JavaScript
1 parent 980ba89 commit fad4ecc

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

url.bs

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,6 +3219,53 @@ e.g., "newURL" and "oldURL".
32193219
naming. [[!HTML]]
32203220

32213221

3222+
<h3 id=urlhost-class>URLHost class</h3>
3223+
3224+
<pre class=idl>
3225+
[Constructor(USVString host),
3226+
Exposed=(Window,Worker)]
3227+
interface URLHost {
3228+
readonly attribute URLHostType type;
3229+
3230+
stringifier USVString toJSON();
3231+
};
3232+
3233+
enum URLHostType { "ipv4", "ipv6", "domain" };</pre>
3234+
3235+
<p>Each {{URLHost}} object has an associated <dfn for=URLHost>host</dfn> (a <a for=/>host</a>).
3236+
3237+
<hr>
3238+
3239+
<p>The <dfn constructor for=URLHost><code>URLHost(<var>input</var>)</code></dfn> constructor, when
3240+
invoked, must run these steps:
3241+
3242+
<ol>
3243+
<li><p>Let <var>host</var> be the result of <a>host parsing</a> <var>input</var> with true.
3244+
3245+
<li><p>If <var>host</var> is failure, then <a>throw</a> a {{TypeError}}.
3246+
3247+
<li><p>Return a new {{URLHost}} object whose <a for=URLHost>host</a> is <var>host</var>.
3248+
</ol>
3249+
3250+
<p>The <dfn attribute for=URLHost><code>type</code></dfn> attribute's getter, must run these steps:
3251+
3252+
<ol>
3253+
<li><p>If <a>this</a>'s <a for=URLHost>host</a> is an <a>IPv4 address</a>, then return
3254+
"<code>ipv4</code>".
3255+
3256+
<li><p>If <a>this</a>'s <a for=URLHost>host</a> is an <a>IPv6 address</a>, then return
3257+
"<code>ipv6</code>".
3258+
3259+
<li><p>Assert: <a>this</a>'s <a for=URLHost>host</a> is an <a>domain</a>.
3260+
3261+
<li><p>Return "<code>domain</code>".
3262+
</ol>
3263+
3264+
<p>The <dfn for=URLHost>stringification behavior</dfn> and
3265+
<dfn method for=URLHost><code>toJSON()</code></dfn> method, when invoked, must return <a>this</a>'s
3266+
<a for=URLHost>host</a>, <a lt="host serializer">serialized</a>.
3267+
3268+
32223269

32233270
<h2 id=acknowledgments class=no-num>Acknowledgments</h2>
32243271

@@ -3317,8 +3364,9 @@ Trevor Rowbotham,
33173364
Valentin Gosu,
33183365
Vyacheslav Matva,
33193366
Wei Wang,
3320-
山岸和利 (Yamagishi Kazutoshi), and
3321-
成瀬ゆい (Yui Naruse)
3367+
山岸和利 (Yamagishi Kazutoshi),
3368+
成瀬ゆい (Yui Naruse), and
3369+
Zach Lym
33223370
for being awesome!
33233371

33243372
<p>This standard is written by

0 commit comments

Comments
 (0)