Socket
Socket
Sign inDemoInstall

uglify-js

Package Overview
Dependencies
0
Maintainers
3
Versions
283
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.11.5 to 3.11.6

26

lib/ast.js

@@ -1018,4 +1018,4 @@ /***********************************************************************

$propdoc: {
key: "[string|AST_SymbolAccessor] property name. For ObjectKeyVal this is a string. For getters and setters this is an AST_SymbolAccessor.",
value: "[AST_Node] property value. For getters and setters this is an AST_Accessor."
key: "[string|AST_Node] property name. For computed property this is an AST_Node.",
value: "[AST_Node] property value. For getters and setters this is an AST_Accessor.",
},

@@ -1025,14 +1025,18 @@ walk: function(visitor) {

visitor.visit(node, function() {
if (node.key instanceof AST_Node) node.key.walk(visitor);
node.value.walk(visitor);
});
}
},
_validate: function() {
if (typeof this.key != "string") {
if (!(this.key instanceof AST_Node)) throw new Error("key must be string or AST_Node");
must_be_expression(this, "key");
}
if (!(this.value instanceof AST_Node)) throw new Error("value must be AST_Node");
},
});
var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", {
var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", null, {
$documentation: "A key: value object property",
$propdoc: {
quote: "[string] the original quote character"
},
_validate: function() {
if (typeof this.key != "string") throw new Error("key must be string");
must_be_expression(this, "value");

@@ -1045,3 +1049,2 @@ },

_validate: function() {
if (!(this.key instanceof AST_SymbolAccessor)) throw new Error("key must be AST_SymbolAccessor");
if (!(this.value instanceof AST_Accessor)) throw new Error("value must be AST_Accessor");

@@ -1054,3 +1057,2 @@ },

_validate: function() {
if (!(this.key instanceof AST_SymbolAccessor)) throw new Error("key must be AST_SymbolAccessor");
if (!(this.value instanceof AST_Accessor)) throw new Error("value must be AST_Accessor");

@@ -1072,6 +1074,2 @@ },

var AST_SymbolAccessor = DEFNODE("SymbolAccessor", null, {
$documentation: "The name of a property accessor (setter/getter function)"
}, AST_Symbol);
var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", {

@@ -1078,0 +1076,0 @@ $documentation: "A declaration symbol (symbol in var, function name or argument, symbol in catch)",

@@ -118,5 +118,2 @@ /***********************************************************************

if (M.kind == "init") return new AST_ObjectKeyVal(args);
args.key = new AST_SymbolAccessor({
name: args.key
});
args.value = new AST_Accessor(args.value);

@@ -389,3 +386,3 @@ if (M.kind == "get") return new AST_ObjectGetter(args);

type: "Literal",
value: M.key instanceof AST_SymbolAccessor ? M.key.name : M.key
value: M.key
};

@@ -392,0 +389,0 @@ var kind;

@@ -702,2 +702,3 @@ /***********************************************************************

|| p instanceof AST_Conditional
// { [(1, 2)]: 3 }[2] ==> 3
// { foo: (1, 2) }.foo ==> 2

@@ -1293,15 +1294,23 @@ || p instanceof AST_ObjectProperty

function print_property_name(key, quote, output) {
if (output.option("quote_keys")) {
function print_property_key(self, output) {
var key = self.key;
if (key instanceof AST_Node) {
output.with_square(function() {
key.print(output);
});
} else if (output.option("quote_keys")) {
output.print_string(key);
} else if ("" + +key == key && key >= 0) {
output.print(make_num(key));
} else if (RESERVED_WORDS[key] ? !output.option("ie8") : is_identifier_string(key)) {
if (quote && output.option("keep_quoted_props")) {
} else {
var quote = self.start && self.start.quote;
if (RESERVED_WORDS[key] ? !output.option("ie8") : is_identifier_string(key)) {
if (quote && output.option("keep_quoted_props")) {
output.print_string(key, quote);
} else {
output.print_name(key);
}
} else {
output.print_string(key, quote);
} else {
output.print_name(key);
}
} else {
output.print_string(key, quote);
}

@@ -1312,3 +1321,3 @@ }

var self = this;
print_property_name(self.key, self.quote, output);
print_property_key(self, output);
output.colon();

@@ -1322,3 +1331,3 @@ self.value.print(output);

output.space();
print_property_name(self.key.name, self.quote, output);
print_property_key(self, output);
self.value._codegen(output, true);

@@ -1495,12 +1504,5 @@ };

DEFMAP([
AST_ObjectGetter,
AST_ObjectSetter,
], function(output) {
output.add_mapping(this.start, this.key.name);
});
DEFMAP([ AST_ObjectProperty ], function(output) {
output.add_mapping(this.start, this.key);
if (typeof this.key == "string") output.add_mapping(this.start, this.key);
});
})();

@@ -756,3 +756,3 @@ /***********************************************************************

var statement = embed_tokens(function(strict_defun) {
var statement = embed_tokens(function() {
handle_regexp();

@@ -848,5 +848,2 @@ switch (S.token.type) {

case "function":
if (!strict_defun && S.input.has_directive("use strict")) {
croak("In strict mode code, functions can only be declared at top level or immediately within another function.");
}
next();

@@ -1043,3 +1040,3 @@ return function_(AST_Defun);

S.labels = [];
var body = block_(true);
var body = block_();
if (S.input.has_directive("use strict")) {

@@ -1073,3 +1070,3 @@ if (name) strict_verify_symbol(name);

function block_(strict_defun) {
function block_() {
expect("{");

@@ -1079,3 +1076,3 @@ var a = [];

if (is("eof")) expect_token("punc", "}");
a.push(statement(strict_defun));
a.push(statement());
}

@@ -1230,3 +1227,3 @@ next();

case "name":
ret = _make_symbol(AST_SymbolRef);
ret = _make_symbol(AST_SymbolRef, tok);
break;

@@ -1349,40 +1346,51 @@ case "num":

if (first) first = false; else expect(",");
if (!options.strict && is("punc", "}"))
// allow trailing comma
break;
// allow trailing comma
if (!options.strict && is("punc", "}")) break;
var start = S.token;
var type = start.type;
var name = as_property_name();
if (type == "name" && !is("punc", ":")) {
var key = new AST_SymbolAccessor({
start: S.token,
name: "" + as_property_name(),
end: prev()
});
if (name == "get") {
a.push(new AST_ObjectGetter({
start : start,
key : key,
value : create_accessor(),
end : prev()
}));
continue;
}
if (name == "set") {
a.push(new AST_ObjectSetter({
start : start,
key : key,
value : create_accessor(),
end : prev()
}));
continue;
}
var key = as_property_key();
if (is("punc", "(")) {
var func_start = S.token;
var func = function_(AST_Function);
func.start = func_start;
func.end = prev();
a.push(new AST_ObjectKeyVal({
start: start,
key: key,
value: func,
end: prev(),
}));
continue;
}
if (!is("punc", ":") && start.type == "name") switch (key) {
case "get":
a.push(new AST_ObjectGetter({
start: start,
key: as_property_key(),
value: create_accessor(),
end: prev(),
}));
continue;
case "set":
a.push(new AST_ObjectSetter({
start: start,
key: as_property_key(),
value: create_accessor(),
end: prev(),
}));
continue;
default:
a.push(new AST_ObjectKeyVal({
start: start,
key: key,
value: _make_symbol(AST_SymbolRef, start),
end: prev(),
}));
continue;
}
expect(":");
a.push(new AST_ObjectKeyVal({
start : start,
quote : start.quote,
key : "" + name,
value : expression(false),
end : prev()
start: start,
key: key,
value: expression(false),
end: prev(),
}));

@@ -1394,3 +1402,3 @@ }

function as_property_name() {
function as_property_key() {
var tmp = S.token;

@@ -1406,3 +1414,9 @@ switch (tmp.type) {

next();
return tmp.value;
return "" + tmp.value;
case "punc":
if (tmp.value != "[") unexpected();
next();
var key = expression(false);
expect("]");
return key;
default:

@@ -1420,8 +1434,8 @@ unexpected();

function _make_symbol(type) {
var name = S.token.value;
return new (name == "this" ? AST_This : type)({
name : String(name),
start : S.token,
end : S.token
function _make_symbol(type, token) {
var name = token.value;
return new (name === "this" ? AST_This : type)({
name: "" + name,
start: token,
end: token,
});

@@ -1440,3 +1454,3 @@ }

}
var sym = _make_symbol(type);
var sym = _make_symbol(type, S.token);
if (S.input.has_directive("use strict") && sym instanceof AST_SymbolDeclaration) {

@@ -1630,3 +1644,3 @@ strict_verify_symbol(sym);

while (!is("eof"))
body.push(statement(true));
body.push(statement());
S.input.pop_directives_stack();

@@ -1633,0 +1647,0 @@ var end = prev();

@@ -84,4 +84,4 @@ /***********************************************************************

ast.walk(new TreeWalker(function(node) {
if (node instanceof AST_ObjectKeyVal) {
if (node.quote) add(node.key);
if (node instanceof AST_ObjectProperty) {
if (node.start && node.start.quote) add(node.key);
} else if (node instanceof AST_Sub) {

@@ -169,7 +169,4 @@ addStrings(node.property, add);

add(node.property);
} else if (node instanceof AST_ObjectKeyVal) {
add(node.key);
} else if (node instanceof AST_ObjectProperty) {
// setter or getter, since KeyVal is handled above
add(node.key.name);
if (typeof node.key == "string") add(node.key);
} else if (node instanceof AST_Sub) {

@@ -203,7 +200,4 @@ addStrings(node.property, add);

node.property = mangle(node.property);
} else if (node instanceof AST_ObjectKeyVal) {
node.key = mangle(node.key);
} else if (node instanceof AST_ObjectProperty) {
// setter or getter
node.key.name = mangle(node.key.name);
if (typeof node.key == "string") node.key = mangle(node.key);
} else if (node instanceof AST_Sub) {

@@ -210,0 +204,0 @@ if (!options.keep_quoted) mangleStrings(node.property);

@@ -167,2 +167,3 @@ /***********************************************************************

DEF(AST_ObjectProperty, function(self, tw) {
if (self.key instanceof AST_Node) self.key = self.key.transform(tw);
self.value = self.value.transform(tw);

@@ -169,0 +170,0 @@ });

@@ -6,3 +6,3 @@ {

"license": "BSD-2-Clause",
"version": "3.11.5",
"version": "3.11.6",
"engines": {

@@ -9,0 +9,0 @@ "node": ">=0.8.0"

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc