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
when enumerable properties are defined on a class's prototype they are not correctly inherited.
The problem is the generate function.
In case of data descriptors no errors occur but the descriptor be dropped (since only the value will be copied).
In case of accessor descriptors errors can occurs (for example if the getter calls something on this) because
and val = obj[key] will trigger the getter to be evaluated with the prototype as context instead of the instance.
Object.getOwnPropertyDescriptor(obj, propName) can be used to determine if an attribute is a defined property or not.
This should be used in both loops - maybe like this:
for own key of next
descriptor=Object.getOwnPropertyDescriptor(next, key)
ifnot descriptor?value= next[key]
@[key] =reparent next, @, value
else# I don't know if this really does itObject.defineProperty@, key, descriptor
I am not quite sure if Object.defineProperty @, key, descriptor does the job.
However, if the descriptor contains get: () -> this.something or get: () -> this.doSomething() (or a setter) the function body is evaluated when property is accessed so I think everything is fine because at that time heterarchy should have taken care of everything, right?
I guess properties on the class itself behave similarly.
Hi,
when enumerable properties are defined on a class's prototype they are not correctly inherited.
The problem is the
generate
function.In case of data descriptors no errors occur but the descriptor be dropped (since only the value will be copied).
In case of accessor descriptors errors can occurs (for example if the getter calls something on
this
) becauseis compiled to
and
val = obj[key]
will trigger the getter to be evaluated with the prototype as context instead of the instance.Object.getOwnPropertyDescriptor(obj, propName)
can be used to determine if an attribute is a defined property or not.This should be used in both loops - maybe like this:
I am not quite sure if
Object.defineProperty @, key, descriptor
does the job.However, if the descriptor contains
get: () -> this.something
orget: () -> this.doSomething()
(or a setter) the function body is evaluated when property is accessed so I think everything is fine because at that time heterarchy should have taken care of everything, right?I guess properties on the class itself behave similarly.
See https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor
The text was updated successfully, but these errors were encountered: