[Pkg-javascript-commits] [uglifyjs] 131/190: Avoid using inherited hasOwnProperty

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Aug 7 23:17:20 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.

commit 931723737204d0a042604f8051ca3af8aa08a1c7
Author: Mihai Bazon <mihai.bazon at gmail.com>
Date:   Thu Apr 7 13:15:28 2016 +0300

    Avoid using inherited hasOwnProperty
    
    Fix #1031
---
 lib/ast.js      |  2 +-
 lib/compress.js |  2 +-
 lib/utils.js    | 14 +++++++++-----
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/ast.js b/lib/ast.js
index 0ac14dc..2a46183 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -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 26c11bd..d42f84d 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 4612a32..c81ca71 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);
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list