diff options
-rw-r--r-- | lib/ast.js | 2 | ||||
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | lib/utils.js | 14 |
3 files changed, 11 insertions, 7 deletions
@@ -71,7 +71,7 @@ function DEFNODE(type, props, methods, base) { if (type) { ctor.prototype.TYPE = ctor.TYPE = type; } - if (methods) for (i in methods) if (methods.hasOwnProperty(i)) { + if (methods) for (i in methods) if (HOP(methods, i)) { if (/^\$/.test(i)) { ctor[i.substr(1)] = methods[i]; } else { diff --git a/lib/compress.js b/lib/compress.js index 26c11bd9..d42f84d1 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2509,7 +2509,7 @@ merge(Compressor.prototype, { if (self.undeclared() && !isLHS(self, compressor.parent())) { var defines = compressor.option("global_defs"); - if (defines && defines.hasOwnProperty(self.name)) { + if (defines && HOP(defines, self.name)) { return make_node_from_constant(compressor, defines[self.name], self); } switch (self.name) { diff --git a/lib/utils.js b/lib/utils.js index 4612a322..c81ca71f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -97,17 +97,17 @@ function defaults(args, defs, croak) { if (args === true) args = {}; var ret = args || {}; - if (croak) for (var i in ret) if (ret.hasOwnProperty(i) && !defs.hasOwnProperty(i)) + if (croak) for (var i in ret) if (HOP(ret, i) && !HOP(defs, i)) DefaultsError.croak("`" + i + "` is not a supported option", defs); - for (var i in defs) if (defs.hasOwnProperty(i)) { - ret[i] = (args && args.hasOwnProperty(i)) ? args[i] : defs[i]; + for (var i in defs) if (HOP(defs, i)) { + ret[i] = (args && HOP(args, i)) ? args[i] : defs[i]; } return ret; }; function merge(obj, ext) { var count = 0; - for (var i in ext) if (ext.hasOwnProperty(i)) { + for (var i in ext) if (HOP(ext, i)) { obj[i] = ext[i]; count++; } @@ -150,7 +150,7 @@ var MAP = (function(){ } } else { - for (i in a) if (a.hasOwnProperty(i)) if (doit()) break; + for (i in a) if (HOP(a, i)) if (doit()) break; } return top.concat(ret); }; @@ -308,3 +308,7 @@ Dictionary.fromObject = function(obj) { dict._size = merge(dict._values, obj); return dict; }; + +function HOP(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} |