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

bug: __proto__ behaves differently from Chrome, Node, and Firefox #16833

Closed
KnorpelSenf opened this issue Nov 26, 2022 · 5 comments · May be fixed by #16775
Closed

bug: __proto__ behaves differently from Chrome, Node, and Firefox #16833

KnorpelSenf opened this issue Nov 26, 2022 · 5 comments · May be fixed by #16775
Labels
invalid what appeared to be an issue with Deno wasn't

Comments

@KnorpelSenf
Copy link
Contributor

KnorpelSenf commented Nov 26, 2022

For some reason, Deno 1.28.2 behaves differently regarding the __proto__ property.

Deno

$ deno
Deno 1.28.2
exit using ctrl+d, ctrl+c, or close()
> let p = '__proto__'
undefined
> let o = {}
undefined
> o
{}
> o[p] = 3
3
> o
{ __proto__: 3 }
>

Node

$ node
Welcome to Node.js v18.9.0.
Type ".help" for more information.
> let p = '__proto__'
undefined
> let o = {}
undefined
> o
{}
> o[p] = 3
3
> o
{}
>

Google Chrome 107.0.5304.110

image

Firefox 102.5.0esr

image

@KnorpelSenf
Copy link
Contributor Author

KnorpelSenf commented Nov 26, 2022

Before anyone asks: no, this is not related to having a newer version of V8. Here is the same bug with a much older version:

$ deno
Deno 1.12.0
exit using ctrl+d or close()
> let p = '__proto__'
undefined
> let o = {}
undefined
> o
{}
> o[p] = 3
3
> o
{ __proto__: 3 }
> 
$ deno --version 
deno 1.12.0 (release, x86_64-unknown-linux-gnu)
v8 9.2.230.14
typescript 4.3.2

Edit: the same is true for 55da1a2.

@bartlomieju
Copy link
Member

It's not a bug, Deno explicitly doesn't have support __proto__, see compat table in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto.

Related #16775

@KnorpelSenf
Copy link
Contributor Author

Fascinating. The background of this issue is that assertEquals from /std fails on Node when compiled by dnt, but it works on Deno. It seems like that is the case because assertEquals converts objects to strings and then compares strings.

This issue will be fixed by #16775. I have opened denoland/dnt#235 on the dnt repo.

@khrj
Copy link
Contributor

khrj commented Nov 26, 2022

Note that #16775 won't completely fix this: The setter will simply warn and fail. Object.setPrototypeOf should be used instead

@dsherret dsherret added the question a question about the use of Deno label Nov 28, 2022
@dsherret
Copy link
Member

See #4324 for more details.

@dsherret dsherret added invalid what appeared to be an issue with Deno wasn't and removed question a question about the use of Deno labels Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid what appeared to be an issue with Deno wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants