Detecting the "type" of a DOM object
David Bruant
bruant.d at gmail.com
Mon Jun 25 06:11:59 PDT 2012
Le 25/06/2012 15:07, Rick Waldron a écrit :
>
> On Monday, June 25, 2012 at 4:28 AM, Brendan Eich wrote:
>
>> David Bruant wrote:
>>> Le 24/06/2012 14:51, Brendan Eich a écrit :
>>>> David Bruant wrote:
>>>>> Instead of adding a new [[instanceofHint]] internal property,
>>>>> maybe the
>>>>> [[NativeBrand]] could be reused.
>>>> +1 on that, which suggests [[NativeBrandMatch]] instead of
>>>> [[InstanceofMatch]].
>>>>
>>>> Your proposal is more general but I think we should extend HasInstance
>>>> only very concretely, with what's needed for WebIDL, and probably for
>>>> any such system that reflects nominal types.
>>> What form would it take?
>>> The constraints of enabling implementations of WebIDL in pure ES6
>>> (which, on the ES side is bound to the goal of getting rid of host
>>> objects) seems to force towards a general proposal.
>>
>> One idea: expose [[NativeBrand]] as a private name object available,
>> depending on implementation details, only to privileged code.
>
> Can you give an example or scenario in which a given piece of code
> would be considered privileged?
>
Firefox is partially built in JavaScript. This code is considered
privileged (by opposition to website JavaScript). More things can be
allowed to this JavaScript code.
In case the DOM is built in pure browser JavaScript (as opposed to
"content JavaScript"), having some privileged-specific capabilities
(like changing dynamically the [[NativeBrand]]) can be useful.
I'm still internally debating whether this particular case would be
useful for writing code or whether it would be just a "spec toy".
David
More information about the es-discuss
mailing list