Skip to content

Commit

Permalink
fix(minifier): cannot transform property key #constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Jan 10, 2025
1 parent 438a6e7 commit 1d3eb51
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,9 @@ impl<'a, 'b> PeepholeSubstituteAlternateSyntax {
};
let PropertyKey::StringLiteral(s) = key else { return };
let value = s.value.as_str();
if matches!(value, "__proto__" | "constructor" | "prototype") {
// Uncaught SyntaxError: Classes may not have a field named 'constructor'
// Uncaught SyntaxError: Class constructor may not be a private method
if matches!(value, "__proto__" | "prototype" | "constructor" | "#constructor") {
return;
}
if *computed {
Expand Down Expand Up @@ -1785,6 +1787,7 @@ mod test {
test_same("class C { ['prototype']() {} }");
test_same("class C { ['__proto__']() {} }");
test_same("class C { ['constructor']() {} }");
test_same("class C { ['#constructor']() {} }");
}

#[test]
Expand Down

0 comments on commit 1d3eb51

Please sign in to comment.