Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/filterStorage.js

Issue 29807560: Issue 6745 - Prefer strict equality operator (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 14, 2018, 4:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/filterNotifier.js ('k') | lib/matcher.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterStorage.js
===================================================================
--- a/lib/filterStorage.js
+++ b/lib/filterStorage.js
@@ -137,17 +137,17 @@
/**
* Removes a filter subscription from the list
* @param {Subscription} subscription filter subscription to be removed
*/
removeSubscription(subscription)
{
for (let i = 0; i < FilterStorage.subscriptions.length; i++)
{
- if (FilterStorage.subscriptions[i].url == subscription.url)
+ if (FilterStorage.subscriptions[i].url === subscription.url)
{
removeSubscriptionFilters(subscription);
FilterStorage.subscriptions.splice(i--, 1);
FilterStorage.knownSubscriptions.delete(subscription.url);
FilterNotifier.triggerListeners("subscription.removed", subscription);
return;
}
@@ -170,17 +170,17 @@
if (insertBefore)
newPos = FilterStorage.subscriptions.indexOf(insertBefore);
if (newPos < 0)
newPos = FilterStorage.subscriptions.length;
if (currentPos < newPos)
newPos--;
- if (currentPos == newPos)
+ if (currentPos === newPos)
return;
FilterStorage.subscriptions.splice(currentPos, 1);
FilterStorage.subscriptions.splice(newPos, 0, subscription);
FilterNotifier.triggerListeners("subscription.moved", subscription);
},
/**
@@ -220,17 +220,17 @@
if (!subscription)
{
// No group for this filter exists, create one
subscription = SpecialSubscription.createForFilter(filter);
this.addSubscription(subscription);
return;
}
- if (typeof position == "undefined")
+ if (typeof position === "undefined")
position = subscription.filters.length;
if (filter.subscriptions.indexOf(subscription) < 0)
filter.subscriptions.push(subscription);
subscription.filters.splice(position, 0, filter);
FilterNotifier.triggerListeners("filter.added", filter, subscription,
position);
},
@@ -250,33 +250,33 @@
subscription ? [subscription] : filter.subscriptions.slice()
);
for (let i = 0; i < subscriptions.length; i++)
{
let currentSubscription = subscriptions[i];
if (currentSubscription instanceof SpecialSubscription)
{
let positions = [];
- if (typeof position == "undefined")
+ if (typeof position === "undefined")
{
let index = -1;
do
{
index = currentSubscription.filters.indexOf(filter, index + 1);
if (index >= 0)
positions.push(index);
} while (index >= 0);
}
else
positions.push(position);
for (let j = positions.length - 1; j >= 0; j--)
{
let currentPosition = positions[j];
- if (currentSubscription.filters[currentPosition] == filter)
+ if (currentSubscription.filters[currentPosition] === filter)
{
currentSubscription.filters.splice(currentPosition, 1);
if (currentSubscription.filters.indexOf(filter) < 0)
{
let index = filter.subscriptions.indexOf(currentSubscription);
if (index >= 0)
filter.subscriptions.splice(index, 1);
}
@@ -295,24 +295,24 @@
* @param {SpecialSubscription} subscription filter group where the filter is
* located
* @param {number} oldPosition current position of the filter
* @param {number} newPosition new position of the filter
*/
moveFilter(filter, subscription, oldPosition, newPosition)
{
if (!(subscription instanceof SpecialSubscription) ||
- subscription.filters[oldPosition] != filter)
+ subscription.filters[oldPosition] !== filter)
{
return;
}
newPosition = Math.min(Math.max(newPosition, 0),
subscription.filters.length - 1);
- if (oldPosition == newPosition)
+ if (oldPosition === newPosition)
return;
subscription.filters.splice(oldPosition, 1);
subscription.filters.splice(newPosition, 0, filter);
FilterNotifier.triggerListeners("filter.moved", filter, subscription,
oldPosition, newPosition);
},
@@ -389,17 +389,17 @@
* @return {Promise} promise resolved or rejected when loading is complete
*/
loadFromDisk()
{
let tryBackup = backupIndex =>
{
return this.restoreBackup(backupIndex, true).then(() =>
{
- if (this.subscriptions.length == 0)
+ if (this.subscriptions.length === 0)
return tryBackup(backupIndex + 1);
}).catch(error =>
{
// Give up
});
};
return IO.statFile(this.sourceFile).then(statData =>
@@ -409,17 +409,17 @@
this.firstRun = true;
return;
}
let parser = this.importData(true);
return IO.readFromFile(this.sourceFile, parser).then(() =>
{
parser(null);
- if (this.subscriptions.length == 0)
+ if (this.subscriptions.length === 0)
{
// No filter subscriptions in the file, this isn't right.
throw new Error("No data in the file");
}
});
}).catch(error =>
{
Cu.reportError(error);
« no previous file with comments | « lib/filterNotifier.js ('k') | lib/matcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld