Commit 096ae57a authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

WebUI: Enforce ESLint eqeqeq rule in c/b/r/extensions/

The rule disallows == in favor of ===, and != in favor of !==, which
matches the Google JS styleguide (which Chromium's JS styleguide
inherits from).

The stricter comparison checks actually revealed a bug in service.js,
which is also fixed in this CL.

Bug: 720034
Change-Id: I2288fe1395c930bf6e541681b500c7ee66c80f97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1959788Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723614}
parent b5a4bc48
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module.exports = {
'env': {
'browser': true,
'es6': true,
},
'rules': {'eqeqeq': ['error', 'always', {'null': 'ignore'}]},
};
......@@ -179,7 +179,7 @@ function groupActivities(activityData) {
*/
function sortActivitiesByCallCount(groupedActivities) {
return Array.from(groupedActivities.values()).sort((a, b) => {
if (a.count != b.count) {
if (a.count !== b.count) {
return b.count - a.count;
}
if (a.key < b.key) {
......
......@@ -72,7 +72,7 @@ Polymer({
return Array.from(this.data.countsByUrl.entries())
.map(e => ({page: e[0], count: e[1]}))
.sort(function(a, b) {
if (a.count != b.count) {
if (a.count !== b.count) {
return b.count - a.count;
}
return a.page < b.page ? -1 : (a.page > b.page ? 1 : 0);
......
......@@ -156,7 +156,7 @@ Polymer({
* @return {boolean}
*/
isStreamEmpty_: function() {
return this.activityStream_.length == 0;
return this.activityStream_.length === 0;
},
/**
......@@ -164,7 +164,7 @@ Polymer({
* @return {boolean}
*/
isFilteredStreamEmpty_: function() {
return this.filteredActivityStream_.length == 0;
return this.filteredActivityStream_.length === 0;
},
/**
......@@ -180,7 +180,7 @@ Polymer({
* @param {!chrome.activityLogPrivate.ExtensionActivity} activity
*/
extensionActivityListener_: function(activity) {
if (activity.extensionId != this.extensionId) {
if (activity.extensionId !== this.extensionId) {
return;
}
......
......@@ -126,7 +126,7 @@ Polymer({
* @return {boolean}
*/
hasWebRequestInfo_: function() {
return !!this.data.webRequestInfo && this.data.webRequestInfo != '{}';
return !!this.data.webRequestInfo && this.data.webRequestInfo !== '{}';
},
/**
......
......@@ -114,7 +114,7 @@ Polymer({
.join('\n');
let visibleAfter = linesAfter.slice(0, visibleLineCountAfter).join('\n');
// If the last character is a \n, force it to be rendered.
if (visibleAfter.charAt(visibleAfter.length - 1) == '\n') {
if (visibleAfter.charAt(visibleAfter.length - 1) === '\n') {
visibleAfter += ' ';
}
......@@ -142,7 +142,7 @@ Polymer({
* @private
*/
getLinesNotShownLabel_(lineCount, stringSingular, stringPluralTemplate) {
return lineCount == 1 ?
return lineCount === 1 ?
stringSingular :
loadTimeData.substituteString(stringPluralTemplate, lineCount);
},
......
......@@ -158,7 +158,8 @@ Polymer({
* @private
*/
isTerminated_: function() {
return this.data.state == chrome.developerPrivate.ExtensionState.TERMINATED;
return this.data.state ===
chrome.developerPrivate.ExtensionState.TERMINATED;
},
/**
......
......@@ -54,7 +54,7 @@ export class DragAndDropHandler {
/** @override */
doDrop(e) {
this.fireDragEnded_();
if (e.dataTransfer.files.length != 1) {
if (e.dataTransfer.files.length !== 1) {
return;
}
......
......@@ -67,7 +67,7 @@ function getRelativeUrl(url, error) {
* @private
*/
function getErrorSeverityText_(item, log, warn, error) {
if (item.type == chrome.developerPrivate.ErrorType.RUNTIME) {
if (item.type === chrome.developerPrivate.ErrorType.RUNTIME) {
switch (item.severity) {
case chrome.developerPrivate.ErrorLevel.LOG:
return log;
......@@ -78,7 +78,7 @@ function getErrorSeverityText_(item, log, warn, error) {
}
assertNotReached();
}
assert(item.type == chrome.developerPrivate.ErrorType.MANIFEST);
assert(item.type === chrome.developerPrivate.ErrorType.MANIFEST);
return warn;
}
......@@ -272,7 +272,7 @@ Polymer({
* @private
*/
computeIsRuntimeError_: function(item) {
return item.type == chrome.developerPrivate.ErrorType.RUNTIME;
return item.type === chrome.developerPrivate.ErrorType.RUNTIME;
},
/**
......@@ -288,7 +288,7 @@ Polymer({
frame.lineNumber;
if (frame.functionName) {
const functionName = frame.functionName == '(anonymous function)' ?
const functionName = frame.functionName === '(anonymous function)' ?
loadTimeData.getString('anonymousFunction') :
frame.functionName;
description += ' (' + functionName + ')';
......@@ -303,7 +303,7 @@ Polymer({
* @private
*/
getStackFrameClass_: function(frame) {
return frame == this.selectedStackFrame_ ? 'selected' : '';
return frame === this.selectedStackFrame_ ? 'selected' : '';
},
/**
......@@ -312,7 +312,7 @@ Polymer({
* @private
*/
getStackFrameTabIndex_: function(frame) {
return frame == this.selectedStackFrame_ ? 0 : -1;
return frame === this.selectedStackFrame_ ? 0 : -1;
},
/**
......@@ -361,9 +361,9 @@ Polymer({
onStackKeydown_: function(e) {
let direction = 0;
if (e.key == 'ArrowDown') {
if (e.key === 'ArrowDown') {
direction = 1;
} else if (e.key == 'ArrowUp') {
} else if (e.key === 'ArrowUp') {
direction = -1;
} else {
return;
......@@ -394,13 +394,13 @@ Polymer({
* @private
*/
computeErrorClass_: function(index) {
return index == this.selectedEntry_ ? 'selected' : '';
return index === this.selectedEntry_ ? 'selected' : '';
},
/** @private */
iconName_: function(index) {
return index == this.selectedEntry_ ? 'icon-expand-less' :
'icon-expand-more';
return index === this.selectedEntry_ ? 'icon-expand-less' :
'icon-expand-more';
},
/**
......@@ -410,7 +410,7 @@ Polymer({
* @private
*/
isOpened_: function(index) {
return index == this.selectedEntry_;
return index === this.selectedEntry_;
},
......@@ -428,7 +428,7 @@ Polymer({
* @private
*/
onErrorItemAction_: function(e) {
if (e.type == 'keydown' && !((e.code == 'Space' || e.code == 'Enter'))) {
if (e.type === 'keydown' && !((e.code === 'Space' || e.code === 'Enter'))) {
return;
}
......@@ -436,6 +436,6 @@ Polymer({
// is pressed.
e.preventDefault();
this.selectedEntry_ =
this.selectedEntry_ == e.model.index ? -1 : e.model.index;
this.selectedEntry_ === e.model.index ? -1 : e.model.index;
},
});
......@@ -132,7 +132,7 @@
.source-icon-wrapper {
align-items: center;
background: rgb(241, 89, 43); /* Same in light & dark modes. */
border-radius: 50%; /* 50% border radius == a circle */
border-radius: 50%; /* 50% border radius === a circle */
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.22),
0 2px 2px 0 rgba(0, 0, 0, 0.12);
display: flex;
......
......@@ -309,7 +309,8 @@ Polymer({
* @private
*/
isTerminated_: function() {
return this.data.state == chrome.developerPrivate.ExtensionState.TERMINATED;
return this.data.state ===
chrome.developerPrivate.ExtensionState.TERMINATED;
},
/**
......@@ -355,8 +356,8 @@ Polymer({
}
const sourceType = getItemSource(this.data);
return sourceType == SourceType.WEBSTORE ? '' :
getItemSourceString(sourceType);
return sourceType === SourceType.WEBSTORE ? '' :
getItemSourceString(sourceType);
},
/**
......@@ -364,7 +365,7 @@ Polymer({
* @private
*/
computeInspectViewsHidden_: function() {
return !this.data.views || this.data.views.length == 0;
return !this.data.views || this.data.views.length === 0;
},
/**
......@@ -408,8 +409,8 @@ Polymer({
// enabled. There's no point in reloading a disabled extension, and we'll
// show a crashed reload button if it's terminated.
const showIcon =
this.data.location == chrome.developerPrivate.Location.UNPACKED &&
this.data.state == chrome.developerPrivate.ExtensionState.ENABLED;
this.data.location === chrome.developerPrivate.Location.UNPACKED &&
this.data.state === chrome.developerPrivate.ExtensionState.ENABLED;
return !showIcon;
},
......
......@@ -121,7 +121,7 @@ Polymer({
/** @private */
onNoExtensionsTap_: function(e) {
if (e.target.tagName == 'A') {
if (e.target.tagName === 'A') {
chrome.metricsPrivate.recordUserAction('Options_GetMoreExtensions');
}
},
......@@ -135,7 +135,7 @@ Polymer({
this.fire('iron-announce', {
text: this.shouldShowEmptySearchMessage_() ?
this.i18n('noSearchResults') :
(total == 1 ?
(total === 1 ?
this.i18n('searchResultsSingular', this.filter) :
this.i18n(
'searchResultsPlural', total.toString(), this.filter)),
......
......@@ -67,7 +67,7 @@ export function userCanChangeEnablement(item) {
return false;
}
// Blacklisted can't be enabled, either.
if (item.state == chrome.developerPrivate.ExtensionState.BLACKLISTED) {
if (item.state === chrome.developerPrivate.ExtensionState.BLACKLISTED) {
return false;
}
......@@ -80,7 +80,7 @@ export function userCanChangeEnablement(item) {
*/
export function getItemSource(item) {
if (item.controlledInfo &&
item.controlledInfo.type ==
item.controlledInfo.type ===
chrome.developerPrivate.ControllerType.POLICY) {
return SourceType.POLICY;
}
......@@ -130,17 +130,17 @@ export function computeInspectableViewLabel(view) {
// Trim the "chrome-extension://<id>/".
const url = new URL(view.url);
let label = view.url;
if (url.protocol == 'chrome-extension:') {
if (url.protocol === 'chrome-extension:') {
label = url.pathname.substring(1);
}
if (label == '_generated_background_page.html') {
if (label === '_generated_background_page.html') {
label = loadTimeData.getString('viewBackgroundPage');
}
// Add any qualifiers.
if (view.incognito) {
label += ' ' + loadTimeData.getString('viewIncognito');
}
if (view.renderProcessId == -1) {
if (view.renderProcessId === -1) {
label += ' ' + loadTimeData.getString('viewInactive');
}
if (view.isIframe) {
......
......@@ -88,7 +88,7 @@ Polymer({
* @private
*/
updateApp_: function(app) {
const index = this.apps_.findIndex(a => a.id == app.id);
const index = this.apps_.findIndex(a => a.id === app.id);
assert(index < this.apps_.length);
this.set('apps_.' + index, app);
},
......
......@@ -46,13 +46,13 @@ const compareExtensions = function(a, b) {
return x < y ? -1 : (x > y ? 1 : 0);
}
function compareLocation(x, y) {
if (x.location == y.location) {
if (x.location === y.location) {
return 0;
}
if (x.location == chrome.developerPrivate.Location.UNPACKED) {
if (x.location === chrome.developerPrivate.Location.UNPACKED) {
return -1;
}
if (y.location == chrome.developerPrivate.Location.UNPACKED) {
if (y.location === chrome.developerPrivate.Location.UNPACKED) {
return 1;
}
return 0;
......@@ -301,7 +301,7 @@ Polymer({
const listId = this.getListId_(eventData.extensionInfo);
const currentIndex = this[listId].findIndex(
item => item.id == eventData.extensionInfo.id);
item => item.id === eventData.extensionInfo.id);
if (currentIndex >= 0) {
this.updateItem_(listId, currentIndex, eventData.extensionInfo);
......@@ -366,7 +366,7 @@ Polymer({
*/
getIndexInList_: function(listId, itemId) {
return this[listId].findIndex(function(item) {
return item.id == itemId;
return item.id === itemId;
});
},
......@@ -407,11 +407,11 @@ Polymer({
*/
addItem_: function(listId, item) {
// We should never try and add an existing item.
assert(this.getIndexInList_(listId, item.id) == -1);
assert(this.getIndexInList_(listId, item.id) === -1);
let insertBeforeChild = this[listId].findIndex(function(listEl) {
return compareExtensions(listEl, item) > 0;
});
if (insertBeforeChild == -1) {
if (insertBeforeChild === -1) {
insertBeforeChild = this[listId].length;
}
this.splice(listId, insertBeforeChild, 0, item);
......@@ -432,16 +432,16 @@ Polymer({
// set the item correctly before opening the page. It's a little weird
// that the DOM will have stale data, but there's no point in causing the
// extra work.
if (this.detailViewItem_ && this.detailViewItem_.id == item.id &&
this.currentPage_.page == Page.DETAILS) {
if (this.detailViewItem_ && this.detailViewItem_.id === item.id &&
this.currentPage_.page === Page.DETAILS) {
this.detailViewItem_ = item;
} else if (
this.errorPageItem_ && this.errorPageItem_.id == item.id &&
this.currentPage_.page == Page.ERRORS) {
this.errorPageItem_ && this.errorPageItem_.id === item.id &&
this.currentPage_.page === Page.ERRORS) {
this.errorPageItem_ = item;
} else if (
this.activityLogItem_ && this.activityLogItem_.id == item.id &&
this.currentPage_.page == Page.ACTIVITY_LOG) {
this.activityLogItem_ && this.activityLogItem_.id === item.id &&
this.currentPage_.page === Page.ACTIVITY_LOG) {
this.activityLogItem_ = item;
}
},
......@@ -454,7 +454,7 @@ Polymer({
// Search for the item to be deleted in |extensions_|.
let listId = 'extensions_';
let index = this.getIndexInList_(listId, itemId);
if (index == -1) {
if (index === -1) {
// If not in |extensions_| it must be in |apps_|.
listId = 'apps_';
index = this.getIndexInList_(listId, itemId);
......@@ -463,10 +463,10 @@ Polymer({
// We should never try and remove a non-existent item.
assert(index >= 0);
this.splice(listId, index, 1);
if ((this.currentPage_.page == Page.ACTIVITY_LOG ||
this.currentPage_.page == Page.DETAILS ||
this.currentPage_.page == Page.ERRORS) &&
this.currentPage_.extensionId == itemId) {
if ((this.currentPage_.page === Page.ACTIVITY_LOG ||
this.currentPage_.page === Page.DETAILS ||
this.currentPage_.page === Page.ERRORS) &&
this.currentPage_.extensionId === itemId) {
// Leave the details page (the 'list' page is a fine choice).
navigation.replaceWith({page: Page.LIST});
}
......@@ -509,7 +509,7 @@ Polymer({
// extension ID is not valid. This enables the use case of seeing an
// extension's install-time activities by navigating to an extension's
// activity log page, then installing the extension.
if (this.showActivityLog && toPage == Page.ACTIVITY_LOG) {
if (this.showActivityLog && toPage === Page.ACTIVITY_LOG) {
activityLogPlaceholder = {
id: newPage.extensionId,
isPlaceholder: true,
......@@ -522,11 +522,11 @@ Polymer({
}
}
if (toPage == Page.DETAILS) {
if (toPage === Page.DETAILS) {
this.detailViewItem_ = assert(data);
} else if (toPage == Page.ERRORS) {
} else if (toPage === Page.ERRORS) {
this.errorPageItem_ = assert(data);
} else if (toPage == Page.ACTIVITY_LOG) {
} else if (toPage === Page.ACTIVITY_LOG) {
if (!this.showActivityLog) {
// Redirect back to the details page if we try to view the
// activity log of an extension but the flag is not set.
......@@ -538,13 +538,13 @@ Polymer({
this.activityLogItem_ = data ? assert(data) : activityLogPlaceholder;
}
if (fromPage != toPage) {
if (fromPage !== toPage) {
/** @type {CrViewManagerElement} */ (this.$.viewManager)
.switchView(/** @type {string} */ (toPage));
}
if (newPage.subpage) {
assert(newPage.subpage == Dialog.OPTIONS);
assert(newPage.subpage === Dialog.OPTIONS);
assert(newPage.extensionId);
this.showOptionsDialog_ = true;
this.async(() => {
......@@ -552,7 +552,7 @@ Polymer({
});
}
document.title = toPage == Page.DETAILS ?
document.title = toPage === Page.DETAILS ?
`${loadTimeData.getString('title')} - ${this.detailViewItem_.name}` :
loadTimeData.getString('title');
this.currentPage_ = newPage;
......@@ -600,7 +600,7 @@ Polymer({
*/
onViewExitStart_: function(e) {
const viewType = e.composedPath()[0].tagName;
this.fromActivityLog_ = viewType == 'EXTENSIONS-ACTIVITY-LOG';
this.fromActivityLog_ = viewType === 'EXTENSIONS-ACTIVITY-LOG';
},
/**
......@@ -609,15 +609,15 @@ Polymer({
*/
onViewExitFinish_: function(e) {
const viewType = e.composedPath()[0].tagName;
if (viewType == 'EXTENSIONS-ITEM-LIST' ||
viewType == 'EXTENSIONS-KEYBOARD-SHORTCUTS' ||
viewType == 'EXTENSIONS-ACTIVITY-LOG') {
if (viewType === 'EXTENSIONS-ITEM-LIST' ||
viewType === 'EXTENSIONS-KEYBOARD-SHORTCUTS' ||
viewType === 'EXTENSIONS-ACTIVITY-LOG') {
return;
}
const extensionId = e.composedPath()[0].data.id;
const list = this.$$('extensions-item-list');
const button = viewType == 'EXTENSIONS-DETAIL-VIEW' ?
const button = viewType === 'EXTENSIONS-DETAIL-VIEW' ?
list.getDetailsButton(extensionId) :
list.getErrorsButton(extensionId);
......
......@@ -36,8 +36,8 @@ export let PageState;
* @return {boolean} Whether a and b are equal.
*/
function isPageStateEqual(a, b) {
return a.page == b.page && a.subpage == b.subpage &&
a.extensionId == b.extensionId;
return a.page === b.page && a.subpage === b.subpage &&
a.extensionId === b.extensionId;
}
/**
......@@ -82,8 +82,8 @@ export class NavigationHelper {
* @private
*/
processRoute_() {
if (this.currentPath_ == '/configureCommands' ||
this.currentPath_ == '/shortcuts') {
if (this.currentPath_ === '/configureCommands' ||
this.currentPath_ === '/shortcuts') {
window.history.replaceState(
undefined /* stateObject */, '', '/shortcuts');
} else if (this.currentPath_ !== '/') {
......@@ -114,7 +114,7 @@ export class NavigationHelper {
return {page: Page.ERRORS, extensionId: id};
}
if (this.currentPath_ == '/shortcuts') {
if (this.currentPath_ === '/shortcuts') {
return {page: Page.SHORTCUTS};
}
......@@ -195,7 +195,7 @@ export class NavigationHelper {
break;
case Page.DETAILS:
if (entry.subpage) {
assert(entry.subpage == Dialog.OPTIONS);
assert(entry.subpage === Dialog.OPTIONS);
path = '/?options=' + entry.extensionId;
} else {
path = '/?id=' + entry.extensionId;
......@@ -211,8 +211,8 @@ export class NavigationHelper {
assert(path);
const state = {url: path};
const currentPage = this.getCurrentPage();
const isDialogNavigation = currentPage.page == entry.page &&
currentPage.extensionId == entry.extensionId;
const isDialogNavigation = currentPage.page === entry.page &&
currentPage.extensionId === entry.extensionId;
// Navigating to a dialog doesn't visually change pages; it just opens
// a dialog. As such, we replace state rather than pushing a new state
// on the stack so that hitting the back button doesn't just toggle the
......
......@@ -15,13 +15,13 @@ import {navigation, Page} from './navigation_helper.js';
* registered yet.
*/
function whenDocumentReady() {
if (document.readyState == 'complete') {
if (document.readyState === 'complete') {
return Promise.resolve();
}
return new Promise(function(resolve) {
document.addEventListener('readystatechange', function f() {
if (document.readyState == 'complete') {
if (document.readyState === 'complete') {
document.removeEventListener('readystatechange', f);
resolve();
}
......@@ -120,7 +120,7 @@ Polymer({
// still on the details page. We could be on a different page if the
// user hit back while the options dialog was visible; in that case, the
// new page is already correct.
if (currentPage && currentPage.page == Page.DETAILS) {
if (currentPage && currentPage.page === Page.DETAILS) {
// This will update the currentPage_ and the NavigationHelper; since
// the active page is already the details page, no main page
// transition occurs.
......
......@@ -115,14 +115,14 @@ Polymer({
onAlertClose_: function(e) {
e.stopPropagation();
if (this.lastResponse_.status ==
if (this.lastResponse_.status ===
chrome.developerPrivate.PackStatus.SUCCESS) {
this.$.dialog.close();
return;
}
// This is only possible for a warning dialog.
if (this.$$('extensions-pack-dialog-alert').returnValue == 'success') {
if (this.$$('extensions-pack-dialog-alert').returnValue === 'success') {
this.delegate.packExtension(
this.lastResponse_.item_path, this.lastResponse_.pem_path,
this.lastResponse_.override_flags, this.onPackResponse_.bind(this));
......
......@@ -119,8 +119,8 @@ Polymer({
const group = /** @type {!HTMLElement} */ (this.$['host-access']);
const access = group.selected;
if (access == chrome.developerPrivate.HostAccess.ON_SPECIFIC_SITES &&
this.permissions.hostAccess !=
if (access === chrome.developerPrivate.HostAccess.ON_SPECIFIC_SITES &&
this.permissions.hostAccess !==
chrome.developerPrivate.HostAccess.ON_SPECIFIC_SITES) {
// If the user is transitioning to the "on specific sites" option, show
// the "add host" dialog. This serves two purposes:
......@@ -142,7 +142,7 @@ Polymer({
* @private
*/
showSpecificSites_: function() {
return this.permissions.hostAccess ==
return this.permissions.hostAccess ===
chrome.developerPrivate.HostAccess.ON_SPECIFIC_SITES;
},
......@@ -200,7 +200,7 @@ Polymer({
// The user canceled the dialog. Set host-access back to the old value,
// if the dialog was shown when just transitioning to a new state.
if (this.oldHostAccess_) {
assert(this.permissions.hostAccess == this.oldHostAccess_);
assert(this.permissions.hostAccess === this.oldHostAccess_);
this.$['host-access'].selected = this.oldHostAccess_;
this.oldHostAccess_ = null;
}
......
......@@ -115,7 +115,7 @@ Polymer({
validate_: function() {
// If input is empty, disable the action button, but don't show the red
// invalid message.
if (this.site_.trim().length == 0) {
if (this.site_.trim().length === 0) {
this.inputInvalid_ = false;
return;
}
......@@ -140,7 +140,7 @@ Polymer({
*/
computeSubmitButtonDisabled_: function() {
return this.inputInvalid_ || this.site_ === undefined ||
this.site_.trim().length == 0;
this.site_.trim().length === 0;
},
/**
......@@ -196,7 +196,7 @@ Polymer({
'Editing host permissions should only be possible if the host ' +
'access is already set to specific sites.');
if (this.currentSite == this.site_) {
if (this.currentSite === this.site_) {
// No change in values, so no need to update anything.
this.$.dialog.close();
return;
......
......@@ -117,7 +117,8 @@ export class Service {
return new Promise(function(resolve, reject) {
chrome.developerPrivate.choosePath(selectType, fileType, function(path) {
if (chrome.runtime.lastError &&
chrome.runtime.lastError != 'File selection was canceled.') {
chrome.runtime.lastError.message !==
'File selection was canceled.') {
reject(chrome.runtime.lastError);
} else {
resolve(path || '');
......@@ -172,7 +173,7 @@ export class Service {
chrome.developerPrivate.loadUnpacked(options, (loadError) => {
if (chrome.runtime.lastError &&
chrome.runtime.lastError.message !=
chrome.runtime.lastError.message !==
'File selection was canceled.') {
throw new Error(chrome.runtime.lastError.message);
}
......
......@@ -107,11 +107,11 @@ Polymer({
* @private
*/
onKeyDown_: function(e) {
if (e.target == this.$.clear) {
if (e.target === this.$.clear) {
return;
}
if (e.keyCode == Key.Escape) {
if (e.keyCode === Key.Escape) {
if (!this.capturing_) {
// If we're not currently capturing, allow escape to propagate.
return;
......@@ -122,7 +122,7 @@ Polymer({
e.stopPropagation();
return;
}
if (e.keyCode == Key.Tab) {
if (e.keyCode === Key.Tab) {
// Allow tab propagation for keyboard navigation.
return;
}
......@@ -143,11 +143,11 @@ Polymer({
// case, the clear button disappears before key-up, so 'Enter's key-up
// target becomes the input field, not the clear button, and needs to
// be caught explicitly.
if (e.target == this.$.clear || e.key == 'Enter') {
if (e.target === this.$.clear || e.key === 'Enter') {
return;
}
if (e.keyCode == Key.Escape || e.keyCode == Key.Tab) {
if (e.keyCode === Key.Escape || e.keyCode === Key.Tab) {
return;
}
......@@ -172,7 +172,7 @@ Polymer({
case ShortcutError.NEED_CHARACTER:
return needCharacter;
default:
assert(this.error_ == ShortcutError.NO_ERROR);
assert(this.error_ === ShortcutError.NO_ERROR);
return '';
}
},
......@@ -257,7 +257,7 @@ Polymer({
* @private
*/
getIsInvalid_: function() {
return this.error_ != ShortcutError.NO_ERROR;
return this.error_ !== ShortcutError.NO_ERROR;
},
/** @private */
......
......@@ -78,11 +78,11 @@ function hasModifier(e, countShiftAsModifier) {
* @return {boolean} Whether the key is valid.
*/
export function isValidKeyCode(keyCode) {
if (keyCode == Key.Escape) {
if (keyCode === Key.Escape) {
return false;
}
for (const k in Key) {
if (Key[k] == keyCode) {
if (Key[k] === keyCode) {
return true;
}
}
......
......@@ -27,7 +27,7 @@ Polymer({
/** @override */
attached: function() {
this.$.sectionMenu.select(
navigation.getCurrentPage().page == Page.SHORTCUTS ? 1 : 0);
navigation.getCurrentPage().page === Page.SHORTCUTS ? 1 : 0);
},
/**
......
......@@ -134,7 +134,7 @@ Polymer({
/** @suppress {suspiciousCode} */ drawer.offsetTop;
}
} else {
if (previous == undefined) {
if (previous === undefined) {
drawer.hidden = true;
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment