Skip to content

Commit

Permalink
fix assigning properties to classes they don't belong in
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiosantoscode committed Sep 26, 2024
1 parent 1ae2885 commit 6e7323f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function* minify_sync_or_async(files, options, _fs_module) {
if (node.block_scope) {
node.block_scope.variables = undefined;
node.block_scope.enclosed = undefined;
node.parent_scope = undefined;
node.block_scope.parent_scope = undefined;
}
});
}
Expand Down
4 changes: 3 additions & 1 deletion lib/propmangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ function mangle_properties(ast, options, annotated_props = find_annotated_props(
} else if (node instanceof AST_ObjectProperty) {
// setter, getter, method or class field
if (!keep_quoted || !node.quote) {
node.key.name = mangle(node.key.name);
if (!node.computed_key()) {
node.key.name = mangle(node.key.name);
}
}
} else if (node instanceof AST_Dot) {
if (!keep_quoted || !node.quote) {
Expand Down
2 changes: 1 addition & 1 deletion lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
scope.parent_scope = this;

// Propagate to this.uses_arguments from arrow functions
if ((scope instanceof AST_Arrow) && !this.uses_arguments) {
if ((scope instanceof AST_Arrow) && (this instanceof AST_Lambda && !this.uses_arguments)) {
this.uses_arguments = walk(scope, node => {
if (
node instanceof AST_SymbolRef
Expand Down
20 changes: 10 additions & 10 deletions test/compress/mangleprops-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,24 @@ computed_inline_string_keep_quoted_strict_no_computed_props: {
let { ['_destructure']: quoted_destructure } = global;

let obj = {
_: "bar",
l() {},
get o() {}
t: "bar",
_() {},
get l() {}
};
let static_class = class {
static i = 'bar';
static p() {}
static get u() {}
static o = 'bar';
static i() {}
static get p() {}
};
let instance_class = class {
j = 'bar';
h() {}
get m() {}
u = 'bar';
j() {}
get h() {}
};
global._sub;
global?._optional_sub;
global?.deep._deep_optional_sub;
let { q: destructure } = global;
let { m: destructure } = global;
}
}

Expand Down
20 changes: 10 additions & 10 deletions test/compress/mangleprops.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,24 @@ computed_inline_string_keep_quoted_no_computed_props: {
let { ['_destructure']: quoted_destructure } = global;

let obj = {
_: "bar",
l() {},
get o() {}
t: "bar",
_() {},
get l() {}
};
let static_class = class {
static i = 'bar';
static p() {}
static get u() {}
static o = 'bar';
static i() {}
static get p() {}
};
let instance_class = class {
j = 'bar';
h() {}
get m() {}
u = 'bar';
j() {}
get h() {}
};
global._sub;
global?._optional_sub;
global?.deep._deep_optional_sub;
let { q: destructure } = global;
let { m: destructure } = global;
}
}

Expand Down

0 comments on commit 6e7323f

Please sign in to comment.