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

Unified Diff: lib/filterClasses.js

Issue 29802575: Issue 6559 - Replace fromObject with fromMap (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 8, 2018, 1:59 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 | « no previous file | lib/filterStorage.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterClasses.js
===================================================================
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -143,30 +143,34 @@
Filter.knownFilters.set(filter.text, filter);
return filter;
};
/**
* Deserializes a filter
*
- * @param {Object} obj map of serialized properties and their values
+ * @param {Map.<string,string>} map map of serialized properties and their
+ * values
* @return {Filter} filter or null if the filter couldn't be created
*/
-Filter.fromObject = function(obj)
+Filter.fromMap = function(map)
{
- let filter = Filter.fromText(obj.text);
+ let filter = Filter.fromText(map.get("text"));
if (filter instanceof ActiveFilter)
{
- if ("disabled" in obj)
- filter._disabled = (obj.disabled == "true");
- if ("hitCount" in obj)
- filter._hitCount = parseInt(obj.hitCount, 10) || 0;
- if ("lastHit" in obj)
- filter._lastHit = parseInt(obj.lastHit, 10) || 0;
+ let disabled = map.get("disabled");
+ let hitCount = map.get("hitCount");
+ let lastHit = map.get("lastHit");
+ if (typeof disabled != "undefined")
+ filter._disabled = (disabled == "true");
+ if (typeof hitCount != "undefined")
+ filter._hitCount = parseInt(hitCount, 10) || 0;
+ if (typeof lastHit != "undefined")
+ filter._lastHit = parseInt(lastHit, 10) || 0;
}
return filter;
};
/**
* Removes unnecessary whitespaces from filter text, will only return null if
* the input parameter is null.
* @param {string} text
« no previous file with comments | « no previous file | lib/filterStorage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld