Skip to content

Commit

Permalink
Define URL's toJSON()
Browse files Browse the repository at this point in the history
This makes it a little easier to use with JSON.stringify().

Tests: web-platform-tests/wpt#4702.

Fixes #137.
  • Loading branch information
annevk authored Feb 8, 2017
1 parent ac6489f commit 7dcfe5b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions url.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,8 @@ interface URL {
attribute USVString search;
[SameObject] readonly attribute URLSearchParams searchParams;
attribute USVString hash;

USVString toJSON();
};
</pre>

Expand Down Expand Up @@ -2569,8 +2571,9 @@ url.pathname // "/%F0%9F%8F%B3%EF%B8%8F%E2%80%8D%F0%9F%8C%88"</pre>

<h3 id=urlutils-members>{{URL}} members</h3>

<p>The <dfn attribute for=URL><code>href</code></dfn> attribute's getter must return the
<a lt='URL serializer'>serialization</a> of <a>context object</a>'s <a for=URL>url</a>.
<p>The <dfn attribute for=URL><code>href</code></dfn> attribute's getter and the
<dfn method for=URL>toJSON()</dfn> method, when invoked, must return the
<a lt="URL serializer">serialization</a> of <a>context object</a>'s <a for=URL>url</a>.

<p>The <code><a attribute for=URL>href</a></code> attribute's setter must run these steps:

Expand Down

0 comments on commit 7dcfe5b

Please sign in to comment.