Skip to content
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

ES2015 Object own keys order issues #1389

Closed
p-bakker opened this issue Oct 2, 2023 · 5 comments · Fixed by #1392
Closed

ES2015 Object own keys order issues #1389

p-bakker opened this issue Oct 2, 2023 · 5 comments · Fixed by #1392
Labels
Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec
Milestone

Comments

@p-bakker
Copy link
Collaborator

p-bakker commented Oct 2, 2023

Rhino doesn't conform to the rules laid out in ES2015 wrt the ordering of own keys in objects

Some quick examples of at least some of the issues:

var x = {'D': true, '-1': true}
x.A = true
x.Z = true
x.V = true
x.h = true

Object.keys(x) // yields [-1, D, A, Z, V, h], should be  [D, -1, A, Z, V, h] as -1 is not an array index key
JSON.stringify(x) // yields {"-1":true,"D":true,"A":true,"Z":true,"V":true,"h":true}, same issue as with Object.keys
JSON.parse(JSON.stringify(x)) // yields {true,D:true,A:true,Z:true,V:true,h:true}: -1 key completely missing so invalid JSON

See:

@p-bakker p-bakker added the Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec label Oct 2, 2023
@p-bakker p-bakker added this to the ES2015 milestone Oct 2, 2023
@rbri
Copy link
Collaborator

rbri commented Oct 2, 2023

At least for HtmlUnit i did some hacking in this way HtmlUnit@e6c4c79

But i guess we can't fix this without breaking the backward compatibility.

@p-bakker
Copy link
Collaborator Author

p-bakker commented Oct 2, 2023

In what way does it break backwards compatibility? Just that the keys will be ordered differently (but properly)?

@gbrail
Copy link
Collaborator

gbrail commented Oct 2, 2023 via email

@p-bakker
Copy link
Collaborator Author

p-bakker commented Oct 2, 2023

I haven't done a full analysis, the same code above was just a quick test I did locally after I saw the many failures in the ES2015 own keys section in the Kangax Compat table

@rbri
Copy link
Collaborator

rbri commented Oct 2, 2023

more details about the HtmlUnit story are here HtmlUnit/htmlunit#595

grafik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants