fixing hasOwnProperty lookups

This commit is contained in:
Danny Yoo 2013-03-07 12:30:41 -07:00
parent 2ff7f10c03
commit d4c9c5efdb
8 changed files with 19 additions and 8 deletions

View File

@ -68,7 +68,7 @@
(display "M.params.currentSuccessHandler = success;\n" op) (display "M.params.currentSuccessHandler = success;\n" op)
(display #<<EOF (display #<<EOF
for (param in params) { for (param in params) {
if (params.hasOwnProperty(param)) { if (Object.hasOwnProperty.call(params, param)) {
M.params[param] = params[param]; M.params[param] = params[param];
} }
} }

View File

@ -733,7 +733,7 @@ var invokeMainModule = function() {
M.params.currentErrorDisplayer( M.params.currentErrorDisplayer(
M, $(plt.baselib.format.toDomNode(e.stack || e)).css('color', 'red')); M, $(plt.baselib.format.toDomNode(e.stack || e)).css('color', 'red'));
if (e.hasOwnProperty('racketError') && if (Object.hasOwnProperty.call(e,'racketError') &&
plt.baselib.exceptions.isExn(e.racketError)) { plt.baselib.exceptions.isExn(e.racketError)) {
contMarkSet = plt.baselib.exceptions.exnContMarks(e.racketError); contMarkSet = plt.baselib.exceptions.exnContMarks(e.racketError);
contextDiv = $('<div/>'); contextDiv = $('<div/>');

View File

@ -199,12 +199,13 @@
var hasOwnProperty = {}.hasOwnProperty;
var ToDomNodeParameters = function(params) { var ToDomNodeParameters = function(params) {
if (! params) { params = {}; } if (! params) { params = {}; }
var k; var k;
for (k in params) { for (k in params) {
if (params.hasOwnProperty(k)) { if (hasOwnProperty.call(params, k)) {
this[k] = params[k]; this[k] = params[k];
} }
} }

View File

@ -13,11 +13,13 @@
}; };
var keywordCache = {}; var keywordCache = {};
var hasOwnProperty = {}.hasOwnProperty;
// makeInstance: string -> Keyword. // makeInstance: string -> Keyword.
Keyword.makeInstance = function (val) { Keyword.makeInstance = function (val) {
// To ensure that we can eq? symbols with equal values. // To ensure that we can eq? symbols with equal values.
if (!(keywordCache.hasOwnProperty(val))) { if (!(hasOwnProperty.call(keywordCache, val))) {
keywordCache[val] = new Keyword(val); keywordCache[val] = new Keyword(val);
} }
return keywordCache[val]; return keywordCache[val];

View File

@ -7,6 +7,8 @@
var exports = {}; var exports = {};
baselib.modules = exports; baselib.modules = exports;
var hasOwnProperty = {}.hasOwnProperty;
var Namespace = function(modrec) { var Namespace = function(modrec) {
this.modrec = modrec; this.modrec = modrec;
@ -20,7 +22,7 @@
}; };
Namespace.prototype.hasKey = function(name) { Namespace.prototype.hasKey = function(name) {
return this.mapping.hasOwnProperty(name); return hasOwnProperty.call(this.mapping, name);
}; };
Namespace.prototype.set = function(name, value) { Namespace.prototype.set = function(name, value) {

View File

@ -69,10 +69,12 @@
// Exports // Exports
var hasOwnProperty = {}.hasOwnProperty;
// We first re-export everything in jsnums. // We first re-export everything in jsnums.
var prop; var prop;
for (prop in jsnums) { for (prop in jsnums) {
if (jsnums.hasOwnProperty(prop)) { if (hasOwnProperty.call(jsnums,prop)) {
exports[prop] = jsnums[prop]; exports[prop] = jsnums[prop];
} }
} }

View File

@ -16,12 +16,14 @@
}; };
var symbolCache = {}; var symbolCache = {};
var hasOwnProperty = {}.hasOwnProperty;
// makeSymbol: string -> Symbol. // makeSymbol: string -> Symbol.
// Interns a symbol. // Interns a symbol.
var makeSymbol = function (val) { var makeSymbol = function (val) {
// To ensure that we can eq? symbols with equal values. // To ensure that we can eq? symbols with equal values.
if (!(symbolCache.hasOwnProperty(val))) { if (!(hasOwnProperty.call(symbolCache,val))) {
symbolCache[val] = new Symbol(val); symbolCache[val] = new Symbol(val);
} }
return symbolCache[val]; return symbolCache[val];

View File

@ -20,6 +20,8 @@ if (!(this.plt)) { this.plt = {}; }
var hasOwnProperty = {}.hasOwnProperty;
// clone: object -> object // clone: object -> object
// Copies an object. The new object should respond like the old // Copies an object. The new object should respond like the old
// object, including to things like instanceof. // object, including to things like instanceof.
@ -29,7 +31,7 @@ if (!(this.plt)) { this.plt = {}; }
C.prototype = obj; C.prototype = obj;
var c = new C(); var c = new C();
for (property in obj) { for (property in obj) {
if (obj.hasOwnProperty(property)) { if (hasOwnProperty.call(obj, property)) {
c[property] = obj[property]; c[property] = obj[property];
} }
} }