Re: [whatwg] Opinions on window.console = "foo", and other oddities of window.console

Generally it should be fine to ask (for any normal person), though
doing a web search first to see if whatever it is caught your
curiousity isn't already covered on stackoverflow, etc is still a good
idea.


On Mon, Feb 8, 2016 at 4:10 PM, Domenic Denicola <d@domenic.me> wrote:
> From: Domenic Denicola
>
>> So I think the plan of record is: `attribute any console`, with prose describing
>> how the getter returns "the window's console object" which is initially set to
>> a new instance of Console, but the setter can change it to any value. This
>> means accessor descriptors and enumerable, since that's how IDL works. If
>> anyone thinks this is bad, let us know. Otherwise the standard will be
>> updated any day now in that direction.
>
> In IRC, Smaug makes me aware of the [Replaceable] IDL attribute, which appears to be what Gecko does. Given `[Replaceable] readonly attribute Console console`, IDL auto-generates a setter that does (essentially) `this.defineOwnProperty("console", { value, writable: true, enumerable: true, configurable: true })`. For most objects this will shadow the prototype's getter, but for global objects like Window it will just overwrite it.
>
> So, new plan of record: `[Replaceable] readonly attribute Console console`.



-- 
Garrett
@xkit
ChordCycles.wordpress.com
garretts.github.io
personx.tumblr.com

Received on Tuesday, 9 February 2016 00:12:20 UTC