do any host object implementations define [[DefaultValue]]??

# Allen Wirfs-Brock (15 years ago)

The ES5 spec. defines [[DefaultValue]] as an internal method but all objects defined by the specification use the default implementation specified in 8.12.8.

Presumably the only reason this algorithm needs to be an "internal method" rather than an "abstract operation" is to allow the possibility that some host objects have different definitions of it. Does this actually occur in browser implementations?

[[DefaultValue]] itself is only directly called from ToPrimitive (9.1). [[DefaultValue]]'s implementation essentially reduces to calls to either or both of the toString and valueOf methods of its this object. If any browser host objects implementation do have unique [[DefaultValue]] implementations do they do anything other than the equivalent of calling their toString or valueOf methods?

You can probably guess whats behind these questions? Is [[DefaultValue]] really an essential part of the ECMAScript internal meta-object protocol?

# Boris Zbarsky (15 years ago)

On 2/9/11 4:20 PM, Allen Wirfs-Brock wrote:

If any browser host objects implementation do have unique [[DefaultValue]] implementations do they do anything other than the equivalent of calling their toString or valueOf methods?

If I'm reading the code right (and I could well not be!), Gecko's JS reflections of NPAPI-provided stuff have a [[DefaultValue]] that purposefully does not call valueOf (see hg.mozilla.org/mozilla-central/file/280e978fc6fb/modules/plugin/base/src/nsJSNPRuntime.cpp#l1686).

There's also some weirdness with NPAPI stuff at hg.mozilla.org/mozilla-central/file/280e978fc6fb/modules/plugin/base/src/nsJSNPRuntime.cpp#l2177.

Also, arbitrary XPConnect objects could define a custom [[DefaultValue]] via their classinfo in Gecko (though as far as I can tell none of the ones we ship in the browser by default do; who knows about extensions).

XPConnect objects without classinfo also use a custom [[DefaultValue]] defined at hg.mozilla.org/mozilla-central/file/280e978fc6fb/js/src/xpconnect/src/xpcwrappednativejsops.cpp#l540

I don't know what other host objects we might have around that use a non-default [[DefaultValue]]; it's a little hard to look through the code for this in Gecko, unfortunately. :(

Of the above, I believe the NPAPI bits are web-exposed and the rest are not (again, modulo whatever extensions do).

# Cameron McCormack (15 years ago)

Allen Wirfs-Brock:

Presumably the only reason this algorithm needs to be an "internal method" rather than an "abstract operation" is to allow the possibility that some host objects have different definitions of it. Does this actually occur in browser implementations?

I defer to Boris and others on what’s implemented in Gecko. Web IDL (as you probably noticed) doesn’t require any special [[DefaultValue]] behaviour.