summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/api.js4
-rw-r--r--ext/bg/js/audio.js6
-rw-r--r--ext/bg/js/backend.js2
-rw-r--r--ext/bg/js/conditions-ui.js20
-rw-r--r--ext/bg/js/conditions.js30
-rw-r--r--ext/bg/js/database.js2
-rw-r--r--ext/bg/js/dictionary.js4
-rw-r--r--ext/bg/js/mecab.js2
-rw-r--r--ext/bg/js/options.js2
-rw-r--r--ext/bg/js/search.js2
-rw-r--r--ext/bg/js/settings-dictionaries.js4
-rw-r--r--ext/bg/js/settings-popup-preview.js2
-rw-r--r--ext/bg/js/translator.js12
13 files changed, 46 insertions, 46 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 766fb0ed..12257e92 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -45,7 +45,7 @@ async function apiOptionsSet(changedOptions, optionsContext, source) {
function modifyOption(path, value, options) {
let pivot = options;
for (const key of path.slice(0, -1)) {
- if (!pivot.hasOwnProperty(key)) {
+ if (!hasOwn(pivot, key)) {
return false;
}
pivot = pivot[key];
@@ -236,7 +236,7 @@ async function apiTemplateRender(template, data, dynamic) {
async function apiCommandExec(command, params) {
const handlers = apiCommandExec.handlers;
- if (handlers.hasOwnProperty(command)) {
+ if (hasOwn(handlers, command)) {
const handler = handlers[command];
handler(params);
}
diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js
index cd42a158..9bbbf902 100644
--- a/ext/bg/js/audio.js
+++ b/ext/bg/js/audio.js
@@ -107,12 +107,12 @@ const audioUrlBuilders = {
'custom': async (definition, optionsContext) => {
const options = await apiOptionsGet(optionsContext);
const customSourceUrl = options.audio.customSourceUrl;
- return customSourceUrl.replace(/\{([^\}]*)\}/g, (m0, m1) => (definition.hasOwnProperty(m1) ? `${definition[m1]}` : m0));
+ return customSourceUrl.replace(/\{([^\}]*)\}/g, (m0, m1) => (hasOwn(definition, m1) ? `${definition[m1]}` : m0));
}
};
async function audioGetUrl(definition, mode, optionsContext, download) {
- if (audioUrlBuilders.hasOwnProperty(mode)) {
+ if (hasOwn(audioUrlBuilders, mode)) {
const handler = audioUrlBuilders[mode];
try {
return await handler(definition, optionsContext, download);
@@ -171,7 +171,7 @@ async function audioInject(definition, fields, sources, optionsContext) {
try {
let audioSourceDefinition = definition;
- if (definition.hasOwnProperty('expressions')) {
+ if (hasOwn(definition, 'expressions')) {
audioSourceDefinition = definition.expressions[0];
}
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 45db9660..4190116b 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -73,7 +73,7 @@ class Backend {
onMessage({action, params}, sender, callback) {
const handlers = Backend.messageHandlers;
- if (handlers.hasOwnProperty(action)) {
+ if (hasOwn(handlers, action)) {
const handler = handlers[action];
const promise = handler(params, sender);
promise.then(
diff --git a/ext/bg/js/conditions-ui.js b/ext/bg/js/conditions-ui.js
index 43c6dc08..cc9db087 100644
--- a/ext/bg/js/conditions-ui.js
+++ b/ext/bg/js/conditions-ui.js
@@ -84,7 +84,7 @@ ConditionsUI.Container = class Container {
createDefaultCondition(type) {
let operator = '';
let value = '';
- if (this.conditionDescriptors.hasOwnProperty(type)) {
+ if (hasOwn(this.conditionDescriptors, type)) {
const conditionDescriptor = this.conditionDescriptors[type];
operator = conditionDescriptor.defaultOperator;
({value} = this.getOperatorDefaultValue(type, operator));
@@ -96,15 +96,15 @@ ConditionsUI.Container = class Container {
}
getOperatorDefaultValue(type, operator) {
- if (this.conditionDescriptors.hasOwnProperty(type)) {
+ if (hasOwn(this.conditionDescriptors, type)) {
const conditionDescriptor = this.conditionDescriptors[type];
- if (conditionDescriptor.operators.hasOwnProperty(operator)) {
+ if (hasOwn(conditionDescriptor.operators, operator)) {
const operatorDescriptor = conditionDescriptor.operators[operator];
- if (operatorDescriptor.hasOwnProperty('defaultValue')) {
+ if (hasOwn(operatorDescriptor, 'defaultValue')) {
return {value: operatorDescriptor.defaultValue, fromOperator: true};
}
}
- if (conditionDescriptor.hasOwnProperty('defaultValue')) {
+ if (hasOwn(conditionDescriptor, 'defaultValue')) {
return {value: conditionDescriptor.defaultValue, fromOperator: false};
}
}
@@ -219,7 +219,7 @@ ConditionsUI.Condition = class Condition {
optionGroup.empty();
const type = this.condition.type;
- if (conditionDescriptors.hasOwnProperty(type)) {
+ if (hasOwn(conditionDescriptors, type)) {
const conditionDescriptor = conditionDescriptors[type];
const operators = conditionDescriptor.operators;
for (const operatorName of Object.keys(operators)) {
@@ -240,23 +240,23 @@ ConditionsUI.Condition = class Condition {
};
const objects = [];
- if (conditionDescriptors.hasOwnProperty(type)) {
+ if (hasOwn(conditionDescriptors, type)) {
const conditionDescriptor = conditionDescriptors[type];
objects.push(conditionDescriptor);
- if (conditionDescriptor.operators.hasOwnProperty(operator)) {
+ if (hasOwn(conditionDescriptor.operators, operator)) {
const operatorDescriptor = conditionDescriptor.operators[operator];
objects.push(operatorDescriptor);
}
}
for (const object of objects) {
- if (object.hasOwnProperty('placeholder')) {
+ if (hasOwn(object, 'placeholder')) {
props.placeholder = object.placeholder;
}
if (object.type === 'number') {
props.type = 'number';
for (const prop of ['step', 'min', 'max']) {
- if (object.hasOwnProperty(prop)) {
+ if (hasOwn(object, prop)) {
props[prop] = object[prop];
}
}
diff --git a/ext/bg/js/conditions.js b/ext/bg/js/conditions.js
index ed4b14f5..c0f0f301 100644
--- a/ext/bg/js/conditions.js
+++ b/ext/bg/js/conditions.js
@@ -18,14 +18,14 @@
function conditionsValidateOptionValue(object, value) {
- if (object.hasOwnProperty('validate') && !object.validate(value)) {
+ if (hasOwn(object, 'validate') && !object.validate(value)) {
throw new Error('Invalid value for condition');
}
- if (object.hasOwnProperty('transform')) {
+ if (hasOwn(object, 'transform')) {
value = object.transform(value);
- if (object.hasOwnProperty('validateTransformed') && !object.validateTransformed(value)) {
+ if (hasOwn(object, 'validateTransformed') && !object.validateTransformed(value)) {
throw new Error('Invalid value for condition');
}
}
@@ -34,12 +34,12 @@ function conditionsValidateOptionValue(object, value) {
}
function conditionsNormalizeOptionValue(descriptors, type, operator, optionValue) {
- if (!descriptors.hasOwnProperty(type)) {
+ if (!hasOwn(descriptors, type)) {
throw new Error('Invalid type');
}
const conditionDescriptor = descriptors[type];
- if (!conditionDescriptor.operators.hasOwnProperty(operator)) {
+ if (!hasOwn(conditionDescriptor.operators, operator)) {
throw new Error('Invalid operator');
}
@@ -48,28 +48,28 @@ function conditionsNormalizeOptionValue(descriptors, type, operator, optionValue
let transformedValue = conditionsValidateOptionValue(conditionDescriptor, optionValue);
transformedValue = conditionsValidateOptionValue(operatorDescriptor, transformedValue);
- if (operatorDescriptor.hasOwnProperty('transformReverse')) {
+ if (hasOwn(operatorDescriptor, 'transformReverse')) {
transformedValue = operatorDescriptor.transformReverse(transformedValue);
}
return transformedValue;
}
function conditionsTestValueThrowing(descriptors, type, operator, optionValue, value) {
- if (!descriptors.hasOwnProperty(type)) {
+ if (!hasOwn(descriptors, type)) {
throw new Error('Invalid type');
}
const conditionDescriptor = descriptors[type];
- if (!conditionDescriptor.operators.hasOwnProperty(operator)) {
+ if (!hasOwn(conditionDescriptor.operators, operator)) {
throw new Error('Invalid operator');
}
const operatorDescriptor = conditionDescriptor.operators[operator];
- if (operatorDescriptor.hasOwnProperty('transform')) {
- if (operatorDescriptor.hasOwnProperty('transformCache')) {
+ if (hasOwn(operatorDescriptor, 'transform')) {
+ if (hasOwn(operatorDescriptor, 'transformCache')) {
const key = `${optionValue}`;
const transformCache = operatorDescriptor.transformCache;
- if (transformCache.hasOwnProperty(key)) {
+ if (hasOwn(transformCache, key)) {
optionValue = transformCache[key];
} else {
optionValue = operatorDescriptor.transform(optionValue);
@@ -93,23 +93,23 @@ function conditionsTestValue(descriptors, type, operator, optionValue, value) {
function conditionsClearCaches(descriptors) {
for (const type in descriptors) {
- if (!descriptors.hasOwnProperty(type)) {
+ if (!hasOwn(descriptors, type)) {
continue;
}
const conditionDescriptor = descriptors[type];
- if (conditionDescriptor.hasOwnProperty('transformCache')) {
+ if (hasOwn(conditionDescriptor, 'transformCache')) {
conditionDescriptor.transformCache = {};
}
const operatorDescriptors = conditionDescriptor.operators;
for (const operator in operatorDescriptors) {
- if (!operatorDescriptors.hasOwnProperty(operator)) {
+ if (!hasOwn(operatorDescriptors, operator)) {
continue;
}
const operatorDescriptor = operatorDescriptors[operator];
- if (operatorDescriptor.hasOwnProperty('transformCache')) {
+ if (hasOwn(operatorDescriptor, 'transformCache')) {
operatorDescriptor.transformCache = {};
}
}
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 9b560f78..c53c9f77 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -137,7 +137,7 @@ class Database {
const visited = {};
const results = [];
const processRow = (row, index) => {
- if (titles.includes(row.dictionary) && !visited.hasOwnProperty(row.id)) {
+ if (titles.includes(row.dictionary) && !hasOwn(visited, row.id)) {
visited[row.id] = true;
results.push(Database.createTerm(row, index));
}
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 9aa0af9c..affce9e9 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -81,7 +81,7 @@ function dictTermsUndupe(definitions) {
const definitionGroups = {};
for (const definition of definitions) {
const definitionExisting = definitionGroups[definition.id];
- if (!definitionGroups.hasOwnProperty(definition.id) || definition.expression.length > definitionExisting.expression.length) {
+ if (!hasOwn(definitionGroups, definition.id) || definition.expression.length > definitionExisting.expression.length) {
definitionGroups[definition.id] = definition;
}
}
@@ -131,7 +131,7 @@ function dictTermsGroup(definitions, dictionaries) {
}
const keyString = key.toString();
- if (groups.hasOwnProperty(keyString)) {
+ if (hasOwn(groups, keyString)) {
groups[keyString].push(definition);
} else {
groups[keyString] = [definition];
diff --git a/ext/bg/js/mecab.js b/ext/bg/js/mecab.js
index 246f8bba..297432e2 100644
--- a/ext/bg/js/mecab.js
+++ b/ext/bg/js/mecab.js
@@ -60,7 +60,7 @@ class Mecab {
}
onNativeMessage({sequence, data}) {
- if (this.listeners.hasOwnProperty(sequence)) {
+ if (hasOwn(this.listeners, sequence)) {
const {callback, timer} = this.listeners[sequence];
clearTimeout(timer);
callback(data);
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 63d88789..358a6b45 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -336,7 +336,7 @@ function profileOptionsSetDefaults(options) {
const combine = (target, source) => {
for (const key in source) {
- if (!target.hasOwnProperty(key)) {
+ if (!hasOwn(target, key)) {
target[key] = source[key];
}
}
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 0922d938..16cbfbbd 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -234,7 +234,7 @@ class DisplaySearch extends Display {
onRuntimeMessage({action, params}, sender, callback) {
const handlers = DisplaySearch.runtimeMessageHandlers;
- if (handlers.hasOwnProperty(action)) {
+ if (hasOwn(handlers, action)) {
const handler = handlers[action];
const result = handler(this, params);
callback(result);
diff --git a/ext/bg/js/settings-dictionaries.js b/ext/bg/js/settings-dictionaries.js
index ebd380ac..177379b0 100644
--- a/ext/bg/js/settings-dictionaries.js
+++ b/ext/bg/js/settings-dictionaries.js
@@ -81,7 +81,7 @@ class SettingsDictionaryListUI {
let changed = false;
let optionsDictionary;
const optionsDictionaries = this.optionsDictionaries;
- if (optionsDictionaries.hasOwnProperty(title)) {
+ if (hasOwn(optionsDictionaries, title)) {
optionsDictionary = optionsDictionaries[title];
} else {
optionsDictionary = SettingsDictionaryListUI.createDictionaryOptions();
@@ -466,7 +466,7 @@ function dictionaryErrorsShow(errors) {
for (let e of errors) {
console.error(e);
e = dictionaryErrorToString(e);
- uniqueErrors[e] = uniqueErrors.hasOwnProperty(e) ? uniqueErrors[e] + 1 : 1;
+ uniqueErrors[e] = hasOwn(uniqueErrors, e) ? uniqueErrors[e] + 1 : 1;
}
for (const e in uniqueErrors) {
diff --git a/ext/bg/js/settings-popup-preview.js b/ext/bg/js/settings-popup-preview.js
index 7d641c46..49409968 100644
--- a/ext/bg/js/settings-popup-preview.js
+++ b/ext/bg/js/settings-popup-preview.js
@@ -106,7 +106,7 @@ class SettingsPopupPreview {
onMessage(e) {
const {action, params} = e.data;
const handlers = SettingsPopupPreview.messageHandlers;
- if (handlers.hasOwnProperty(action)) {
+ if (hasOwn(handlers, action)) {
const handler = handlers[action];
handler(this, params);
}
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index e27cbdff..0a0ce663 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -297,7 +297,7 @@ class Translator {
for (const deinflection of deinflections) {
const term = deinflection.term;
let deinflectionArray;
- if (uniqueDeinflectionsMap.hasOwnProperty(term)) {
+ if (hasOwn(uniqueDeinflectionsMap, term)) {
deinflectionArray = uniqueDeinflectionsMap[term];
} else {
deinflectionArray = [];
@@ -355,7 +355,7 @@ class Translator {
const kanjiUnique = {};
const kanjiList = [];
for (const c of text) {
- if (!kanjiUnique.hasOwnProperty(c)) {
+ if (!hasOwn(kanjiUnique, c)) {
kanjiList.push(c);
kanjiUnique[c] = true;
}
@@ -417,7 +417,7 @@ class Translator {
const expression = term.expression;
term.frequencies = [];
- if (termsUniqueMap.hasOwnProperty(expression)) {
+ if (hasOwn(termsUniqueMap, expression)) {
termsUniqueMap[expression].push(term);
} else {
const termList = [term];
@@ -464,7 +464,7 @@ class Translator {
const category = meta.category;
const group = (
- stats.hasOwnProperty(category) ?
+ hasOwn(stats, category) ?
stats[category] :
(stats[category] = [])
);
@@ -484,7 +484,7 @@ class Translator {
async getTagMetaList(names, title) {
const tagMetaList = [];
const cache = (
- this.tagCache.hasOwnProperty(title) ?
+ hasOwn(this.tagCache, title) ?
this.tagCache[title] :
(this.tagCache[title] = {})
);
@@ -492,7 +492,7 @@ class Translator {
for (const name of names) {
const base = Translator.getNameBase(name);
- if (cache.hasOwnProperty(base)) {
+ if (hasOwn(cache, base)) {
tagMetaList.push(cache[base]);
} else {
const tagMeta = await this.database.findTagForTitle(base, title);