You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.
Per the current spec, this should print undefined. Per every implementation, this should print the get property of the foo property descriptor on x (i.e., the function).
As far as I can tell, __lookupGetter__ (with __lookupSetter__ being a very slight variation on this with .get replaced by .set) should be:
…where all the built-ins have their initial values (i.e., Object.prototype, Object.getOwnPropertyDescriptor, Object.getPrototypeOf, and undefined).
Now, to look at the define variants:
Set the internal [[Enumerable]] property of obj’s prop property to true.
What if obj doesn't have a prop property? In a case like var x = {}; x.__defineGetter__("foo", function(){return 1}); there is no foo property on x, as where would it come from?
Whenever a property with the name of prop is accessed on the obj object, call function with the this binding set to obj, and return the result.
What does this even mean? What should the following do:
Is this accessing the property? What on earth should the object that Object.getOwnPropertyDescriptor look like? You've not created a property descriptor for foo, you've just magically defined its behaviour!
As far as I can tell, the actual behaviour is the following (again, assuming all built-ins have their initial value, and the setter variant just being the set property and not the get property):
Object.prototype.__defineGetter__=function(propertyName,func){if(typeoffunc!=="function")throwTypeError("not a function");Object.defineProperty(this,propertyName,{get: func,enumerable: true});}
As it is now, it is pretty much totally undefined how these functions relate to the ES object model (just some handwaving about "whenever a property with name of prop is accessed on the obj object").
The text was updated successfully, but these errors were encountered:
Consider the following:
Per the current spec, this should print undefined. Per every implementation, this should print the
get
property of thefoo
property descriptor onx
(i.e., the function).As far as I can tell,
__lookupGetter__
(with__lookupSetter__
being a very slight variation on this with.get
replaced by.set
) should be:…where all the built-ins have their initial values (i.e.,
Object.prototype
,Object.getOwnPropertyDescriptor
,Object.getPrototypeOf
, andundefined
).Now, to look at the
define
variants:What if
obj
doesn't have aprop
property? In a case likevar x = {}; x.__defineGetter__("foo", function(){return 1});
there is nofoo
property onx
, as where would it come from?What does this even mean? What should the following do:
Is this accessing the property? What on earth should the object that
Object.getOwnPropertyDescriptor
look like? You've not created a property descriptor forfoo
, you've just magically defined its behaviour!As far as I can tell, the actual behaviour is the following (again, assuming all built-ins have their initial value, and the setter variant just being the
set
property and not theget
property):As it is now, it is pretty much totally undefined how these functions relate to the ES object model (just some handwaving about "whenever a property with name of
prop
is accessed on theobj
object").The text was updated successfully, but these errors were encountered: