-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object.assign is broken after 1.7.15 with custom ScriptableObjects #1558
Comments
Added the |
I was playing with this a bit in a project that is using RhinoJS and I am not able to fix it on my end as
rhino/rhino/src/main/java/org/mozilla/javascript/AbstractEcmaObjectOperations.java Line 210 in cbb0e2f
The |
I would like to fix this before the releease. My current idea is:
|
This is fixed by the PR, although it requires classes that override ScriptableObject to manage their own property access a bit differently -- take a look at the PR and the associated tests. |
The issue
This is related to #780, which changed how
Object.assign
works. That change makes sense as it aligns the implementation with the ECMA specification. However it is a breaking change for all customScriptableObject
based classes (not only inside RhinoJS itself, but in depending projects as well).Symptoms
Classes extending
ScriptableObject
quite often only override basicget
/put
/has
/getIds
methods. Trying to useObject.assign
ends with error due to missing attribute slot:rhino/rhino/src/main/java/org/mozilla/javascript/ScriptableObject.java
Line 486 in cc302b4
rhino/rhino/src/main/java/org/mozilla/javascript/ScriptableObject.java
Line 2598 in cc302b4
Quick solution to the issue
The first solution that comes to my mind is to make sure that missing attribute slot does not end with exception... at least not in case when called from
Object.assign
as the specification clearly states the following:So undefined property attributes is a well defined state... the property should be skipped.
Proper solution
Previous quick solution still means 1.7.15+ brought breaking changes for custom
ScriptableObject
implementations. I would appreciate if there would be clear example how customNativeObject
/IdScriptableObject
/ScriptableObject
should be implemented... in the case ofIdScriptableObject
implementation I guess one needs to overridefindInstanceIdInfo
method?Footnote
Not sure if this is a partial duplicate of #1549. That issue's description is a bit cryptic for me.
The text was updated successfully, but these errors were encountered: