Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
fix(service): use hasOwnProperty of prototype #638
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Marton authored and knalli committed Sep 7, 2014
1 parent b951fd5 commit d8a5060
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/directive/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ angular.module('pascalprecht.translate')
});
};
for (var attr in iAttr) {
if (iAttr.hasOwnProperty(attr) && attr.substr(0, 14) === 'translateValue' && attr !== 'translateValues') {
if (Object.prototype.hasOwnProperty.call(iAttr, attr) && attr.substr(0, 14) === 'translateValue' && attr !== 'translateValues') {
fn(attr);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/service/default-interpolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ angular.module('pascalprecht.translate').factory('$translateDefaultInterpolation
escaped: function (params) {
var result = {};
for (var key in params) {
if (params.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(params, key)) {
result[key] = angular.element('<div></div>').text(params[key]).html();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/service/loader-partial.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ angular.module('pascalprecht.translate')
var parts = {};

function hasPart(name) {
return parts.hasOwnProperty(name);
return Object.prototype.hasOwnProperty.call(parts, name);
}

function isStringValid(str) {
Expand Down
2 changes: 1 addition & 1 deletion src/service/messageformat-interpolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ angular.module('pascalprecht.translate')
escaped: function (params) {
var result = {};
for (var key in params) {
if (params.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(params, key)) {
result[key] = angular.element('<div></div>').text(params[key]).html();
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/service/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
var alias;
for (var langKeyAlias in $languageKeyAliases) {
var hasWildcardKey = false;
var hasExactKey = $languageKeyAliases.hasOwnProperty(langKeyAlias) &&
var hasExactKey = Object.prototype.hasOwnProperty.call($languageKeyAliases, langKeyAlias) &&
angular.lowercase(langKeyAlias) === angular.lowercase(preferred);

if (langKeyAlias.slice(-1) === '*') {
Expand All @@ -114,7 +114,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',

var parts = preferred.split('_');

if (parts.length > 1 && avail.indexOf(angular.lowercase(parts[0])) > -1) {
if (parts.length > 1 && indexOf(avail, angular.lowercase(parts[0])) > -1) {
return parts[0];
}

Expand Down Expand Up @@ -217,7 +217,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
result = {};
}
for (key in data) {
if (!data.hasOwnProperty(key)) {
if (!Object.prototype.hasOwnProperty.call(data, key)) {
continue;
}
val = data[key];
Expand Down Expand Up @@ -411,7 +411,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
$fallbackWasString = false;
$fallbackLanguage = langKey;
}
if (angular.isString($preferredLanguage) && $fallbackLanguage.indexOf($preferredLanguage) < 0) {
if (angular.isString($preferredLanguage) && indexOf($fallbackLanguage, $preferredLanguage) < 0) {
$fallbackLanguage.push($preferredLanguage);
}

Expand Down Expand Up @@ -966,7 +966,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
*/
var getTranslationTable = function (langKey) {
var deferred = $q.defer();
if ($translationTable.hasOwnProperty(langKey)) {
if (Object.prototype.hasOwnProperty.call($translationTable, langKey)) {
deferred.resolve($translationTable[langKey]);
return deferred.promise;
} else {
Expand Down Expand Up @@ -997,7 +997,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
var deferred = $q.defer();

getTranslationTable(langKey).then(function (translationTable) {
if (translationTable.hasOwnProperty(translationId)) {
if (Object.prototype.hasOwnProperty.call(translationTable, translationId)) {
Interpolator.setLocale(langKey);
deferred.resolve(Interpolator.interpolate(translationTable[translationId], interpolateParams));
Interpolator.setLocale($uses);
Expand Down Expand Up @@ -1026,7 +1026,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
var getFallbackTranslationInstant = function (langKey, translationId, interpolateParams, Interpolator) {
var result, translationTable = $translationTable[langKey];

if (translationTable.hasOwnProperty(translationId)) {
if (Object.prototype.hasOwnProperty.call(translationTable, translationId)) {
Interpolator.setLocale(langKey);
result = Interpolator.interpolate(translationTable[translationId], interpolateParams);
Interpolator.setLocale($uses);
Expand Down Expand Up @@ -1157,7 +1157,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
Interpolator = (interpolationId) ? interpolatorHashMap[interpolationId] : defaultInterpolator;

// if the translation id exists, we can just interpolate it
if (table && table.hasOwnProperty(translationId)) {
if (table && Object.prototype.hasOwnProperty.call(table, translationId)) {
var translation = table[translationId];

// If using link, rerun $translate with linked translationId and return it
Expand Down Expand Up @@ -1203,7 +1203,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
Interpolator = (interpolationId) ? interpolatorHashMap[interpolationId] : defaultInterpolator;

// if the translation id exists, we can just interpolate it
if (table && table.hasOwnProperty(translationId)) {
if (table && Object.prototype.hasOwnProperty.call(table, translationId)) {
var translation = table[translationId];

// If using link, rerun $translate with linked translationId and return it
Expand Down Expand Up @@ -1590,7 +1590,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',

// trim off any whitespace
if (translationId) {
translationId = translationId.trim();
translationId = trim.apply(translationId);
}

var result, possibleLangKeys = [];
Expand Down

0 comments on commit d8a5060

Please sign in to comment.