Permalink
Browse files

Use hasOwnProperty instead of direct object lookup. [Fixes #2529375]

  • Loading branch information...
rgrove committed Mar 30, 2011
1 parent 9bd942e commit b48b1edab719611a151f25cb7473e8053d086ebe
Showing with 40 additions and 16 deletions.
  1. +13 −5 build/history/history-debug.js
  2. +1 −1 build/history/history-min.js
  3. +13 −5 build/history/history.js
  4. +13 −5 src/history/js/history.js
@@ -310,7 +310,10 @@ YAHOO.util.History = (function () {
if (tokens.length === 2) {
moduleName = tokens[0];
initialState = tokens[1];
- moduleObj = _modules[moduleName];
+
+ moduleObj = YAHOO.lang.hasOwnProperty(_modules, moduleName)
+ && _modules[moduleName];
+
if (moduleObj) {
moduleObj.initialState = initialState;
}
@@ -323,7 +326,10 @@ YAHOO.util.History = (function () {
if (tokens.length >= 2) {
moduleName = tokens[0];
currentState = tokens[1];
- moduleObj = _modules[moduleName];
+
+ moduleObj = YAHOO.lang.hasOwnProperty(_modules, moduleName)
+ && _modules[moduleName];
+
if (moduleObj) {
moduleObj.currentState = currentState;
}
@@ -486,7 +492,7 @@ YAHOO.util.History = (function () {
throw new Error("Missing or invalid argument");
}
- if (_modules[module]) {
+ if (YAHOO.lang.hasOwnProperty(_modules, module)) {
// Here, we used to throw an exception. However, users have
// complained about this behavior, so we now just return.
return;
@@ -634,7 +640,7 @@ YAHOO.util.History = (function () {
}
for (moduleName in states) {
- if (!_modules[_encode(moduleName)]) {
+ if (!YAHOO.lang.hasOwnProperty(_modules, _encode(moduleName))) {
throw new Error("The following module has not been registered: " + moduleName);
}
}
@@ -701,7 +707,9 @@ YAHOO.util.History = (function () {
throw new Error("The Browser History Manager is not initialized");
}
- moduleObj = _modules[module];
+ moduleObj = YAHOO.lang.hasOwnProperty(_modules, module)
+ && _modules[module];
+
if (!moduleObj) {
throw new Error("No such registered module: " + module);
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -310,7 +310,10 @@ YAHOO.util.History = (function () {
if (tokens.length === 2) {
moduleName = tokens[0];
initialState = tokens[1];
- moduleObj = _modules[moduleName];
+
+ moduleObj = YAHOO.lang.hasOwnProperty(_modules, moduleName)
+ && _modules[moduleName];
+
if (moduleObj) {
moduleObj.initialState = initialState;
}
@@ -323,7 +326,10 @@ YAHOO.util.History = (function () {
if (tokens.length >= 2) {
moduleName = tokens[0];
currentState = tokens[1];
- moduleObj = _modules[moduleName];
+
+ moduleObj = YAHOO.lang.hasOwnProperty(_modules, moduleName)
+ && _modules[moduleName];
+
if (moduleObj) {
moduleObj.currentState = currentState;
}
@@ -486,7 +492,7 @@ YAHOO.util.History = (function () {
throw new Error("Missing or invalid argument");
}
- if (_modules[module]) {
+ if (YAHOO.lang.hasOwnProperty(_modules, module)) {
// Here, we used to throw an exception. However, users have
// complained about this behavior, so we now just return.
return;
@@ -634,7 +640,7 @@ YAHOO.util.History = (function () {
}
for (moduleName in states) {
- if (!_modules[_encode(moduleName)]) {
+ if (!YAHOO.lang.hasOwnProperty(_modules, _encode(moduleName))) {
throw new Error("The following module has not been registered: " + moduleName);
}
}
@@ -701,7 +707,9 @@ YAHOO.util.History = (function () {
throw new Error("The Browser History Manager is not initialized");
}
- moduleObj = _modules[module];
+ moduleObj = YAHOO.lang.hasOwnProperty(_modules, module)
+ && _modules[module];
+
if (!moduleObj) {
throw new Error("No such registered module: " + module);
}
View
@@ -310,7 +310,10 @@ YAHOO.util.History = (function () {
if (tokens.length === 2) {
moduleName = tokens[0];
initialState = tokens[1];
- moduleObj = _modules[moduleName];
+
+ moduleObj = YAHOO.lang.hasOwnProperty(_modules, moduleName)
+ && _modules[moduleName];
+
if (moduleObj) {
moduleObj.initialState = initialState;
}
@@ -323,7 +326,10 @@ YAHOO.util.History = (function () {
if (tokens.length >= 2) {
moduleName = tokens[0];
currentState = tokens[1];
- moduleObj = _modules[moduleName];
+
+ moduleObj = YAHOO.lang.hasOwnProperty(_modules, moduleName)
+ && _modules[moduleName];
+
if (moduleObj) {
moduleObj.currentState = currentState;
}
@@ -486,7 +492,7 @@ YAHOO.util.History = (function () {
throw new Error("Missing or invalid argument");
}
- if (_modules[module]) {
+ if (YAHOO.lang.hasOwnProperty(_modules, module)) {
// Here, we used to throw an exception. However, users have
// complained about this behavior, so we now just return.
return;
@@ -634,7 +640,7 @@ YAHOO.util.History = (function () {
}
for (moduleName in states) {
- if (!_modules[_encode(moduleName)]) {
+ if (!YAHOO.lang.hasOwnProperty(_modules, _encode(moduleName))) {
throw new Error("The following module has not been registered: " + moduleName);
}
}
@@ -701,7 +707,9 @@ YAHOO.util.History = (function () {
throw new Error("The Browser History Manager is not initialized");
}
- moduleObj = _modules[module];
+ moduleObj = YAHOO.lang.hasOwnProperty(_modules, module)
+ && _modules[module];
+
if (!moduleObj) {
throw new Error("No such registered module: " + module);
}

0 comments on commit b48b1ed

Please sign in to comment.