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

Don't rewrite __proto__ to shorthand. #3651

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/js_parser/js_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,7 @@ func TestObject(t *testing.T) {

expectPrintedMangle(t, "x = {['_proto_']: x}", "x = { _proto_: x };\n")
expectPrintedMangle(t, "x = {['__proto__']: x}", "x = { [\"__proto__\"]: x };\n")
expectPrinted(t, "({ __proto__: __proto__ })", "({ __proto__: __proto__ });\n")

expectParseError(t, "({set foo() {}})", "<stdin>: ERROR: Setter \"foo\" must have exactly one argument\n")
expectParseError(t, "({get foo(x) {}})", "<stdin>: ERROR: Getter \"foo\" must have zero arguments\n")
Expand Down
2 changes: 1 addition & 1 deletion internal/js_printer/js_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ func (p *printer) printProperty(property js_ast.Property) {
if !p.options.UnsupportedFeatures.Has(compat.ObjectExtensions) && property.ValueOrNil.Data != nil && !p.willPrintExprCommentsAtLoc(property.ValueOrNil.Loc) {
switch e := property.ValueOrNil.Data.(type) {
case *js_ast.EIdentifier:
if helpers.UTF16EqualsString(key.Value, p.renamer.NameForSymbol(e.Ref)) {
if helpers.UTF16EqualsString(key.Value, p.renamer.NameForSymbol(e.Ref)) && !helpers.UTF16EqualsString(key.Value, "__proto__") {
if p.options.AddSourceMappings {
p.addSourceMappingForName(property.Key.Loc, helpers.UTF16ToString(key.Value), e.Ref)
}
Expand Down