Skip to content

Commit

Permalink
Use Object.prototype.hasOwnProperty.call instead of obj.hasOwnProperty.
Browse files Browse the repository at this point in the history
Fixes #888
  • Loading branch information
mbest committed Dec 3, 2016
1 parent 766af4c commit 1523efb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/customElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
// Give access to the raw computeds, as long as that wouldn't overwrite any custom param also called '$raw'
// This is in case the developer wants to react to outer (binding) observability separately from inner
// (model value) observability, or in case the model value observable has subobservables.
if (!result.hasOwnProperty('$raw')) {
if (!Object.prototype.hasOwnProperty.call(result, '$raw')) {
result['$raw'] = rawParamComputedValues;
}

Expand Down Expand Up @@ -104,7 +104,7 @@
var newDocFrag = originalFunction(),
allComponents = ko.components._allRegisteredComponents;
for (var componentName in allComponents) {
if (allComponents.hasOwnProperty(componentName)) {
if (Object.prototype.hasOwnProperty.call(allComponents, componentName)) {
newDocFrag.createElement(componentName);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/defaultLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
};

ko.components.isRegistered = function(componentName) {
return defaultConfigRegistry.hasOwnProperty(componentName);
return Object.prototype.hasOwnProperty.call(defaultConfigRegistry, componentName);
};

ko.components.unregister = function(componentName) {
Expand All @@ -35,7 +35,7 @@

ko.components.defaultLoader = {
'getConfig': function(componentName, callback) {
var result = defaultConfigRegistry.hasOwnProperty(componentName)
var result = ko.components.isRegistered(componentName)
? defaultConfigRegistry[componentName]
: null;
callback(result);
Expand Down
2 changes: 1 addition & 1 deletion src/components/loaderRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
};

function getObjectOwnProperty(obj, propName) {
return obj.hasOwnProperty(propName) ? obj[propName] : undefined;
return Object.prototype.hasOwnProperty.call(obj, propName) ? obj[propName] : undefined;
}

function loadComponentAndNotify(componentName, callback) {
Expand Down
2 changes: 1 addition & 1 deletion src/subscribables/dependentObservable.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ var computedFn = {
haveDependenciesChanged: function () {
var id, dependency, dependencyTracking = this[computedState].dependencyTracking;
for (id in dependencyTracking) {
if (dependencyTracking.hasOwnProperty(id)) {
if (Object.prototype.hasOwnProperty.call(dependencyTracking, id)) {
dependency = dependencyTracking[id];
if (dependency._target.hasChanged(dependency._version)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/templating/templateRewriting.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ko.templateRewriting = (function () {
var allValidators = ko.expressionRewriting.bindingRewriteValidators;
for (var i = 0; i < keyValueArray.length; i++) {
var key = keyValueArray[i]['key'];
if (allValidators.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(allValidators, key)) {
var validator = allValidators[key];

if (typeof validator === "function") {
Expand Down
8 changes: 5 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
ko.utils = (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty;

function objectForEach(obj, action) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
if (hasOwnProperty.call(obj, prop)) {
action(prop, obj[prop]);
}
}
Expand All @@ -10,7 +12,7 @@ ko.utils = (function () {
function extend(target, source) {
if (source) {
for(var prop in source) {
if(source.hasOwnProperty(prop)) {
if(hasOwnProperty.call(source, prop)) {
target[prop] = source[prop];
}
}
Expand Down Expand Up @@ -190,7 +192,7 @@ ko.utils = (function () {
return source;
var target = {};
for (var prop in source) {
if (source.hasOwnProperty(prop)) {
if (hasOwnProperty.call(source, prop)) {
target[prop] = mapping(source[prop], prop, source);
}
}
Expand Down

0 comments on commit 1523efb

Please sign in to comment.