Skip to content

Commit

Permalink
Make console a namespace
Browse files Browse the repository at this point in the history
But, add an empty object to its prototype chain, for web-compatibility. Closes #3! Also closes #55, since Web IDL specifies the property descriptor for namespace objects.
  • Loading branch information
domenic committed Oct 17, 2016
1 parent 694cce7 commit 9a0792d
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ implementation-chosen limit (typically on the order of at least 100).
</code></pre>
</div>

<h2 id="console-interface">Interface <code>Console</code></h2>
<h2 id="console-namespace" oldids="console-interface">Namespace <code>console</code></h2>

<pre class="idl">
[NoInterfaceObject, Exposed=(Window,Worker)]
interface Console {
[Exposed=(Window,Worker)]
namespace console { // but see namespace object requirements below
// Logging
void assert(optional boolean condition = false, any... data);
void clear();
Expand All @@ -199,22 +199,22 @@ interface Console {
void time(optional DOMString label = "default");
void timeEnd(optional DOMString label = "default");
};

partial interface Window {
[Replaceable] readonly attribute Console console;
};

partial interface WorkerGlobalScope {
[Replaceable] readonly attribute Console console;
};
</pre>

<p class="note">
It is important that <code>console</code> is always visible
For historical reasons, {{console}} is lowercased.
</p>

<p class="note">
It is important that {{console}} is always visible
and usable to scripts, even if the developer console has not been opened or
does not exist.
</p>

For historical web-compatibility reasons, the <a>namespace object</a> for {{console}} must have as
its \[[Prototype]] an empty object, created as if by ObjectCreate(%ObjectPrototype%), instead of
%ObjectPrototype%.

<h3 id="logging">Logging methods</h3>

<h4><dfn method for="Console">assert(<var>condition</var>, ...<var>data</var>)</dfn></h4>
Expand Down Expand Up @@ -291,13 +291,16 @@ TODO: Define an interface that allows JavaScript objects to format themselves fo
<h2 id="acks" class="no-num">Acknowledgments</h2>

The editors would like to thank
Brent S.A. Cowgill
Boris Zbarsky,
Brent S.A. Cowgill,
Brian Grinstead,
Corey Farwell,
Jeff Carpenter,
Joseph Pecoraro,
Justin Woo,
Paul Irish
and Raphaël
Paul Irish,
Raphaël, and
Victor Costan
for their contributions to this specification. You are awesome!

This standard is written by <a href="https://terinstock.com">Terin Stock</a> (<a
Expand Down

0 comments on commit 9a0792d

Please sign in to comment.