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

Unified Diff: lib/filterClasses.js

Issue 29361640: Issue 4593 - Support regular expressions for CSS property matching (Closed) Base URL: https://bitbucket.org/fhd/adblockpluscore
Patch Set: Use String.prototype.startsWith/.endsWith Created Nov. 3, 2016, 7:05 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 | test/filterClasses.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
@@ -1037,13 +1037,17 @@
get regexpString()
{
// Despite this property being cached, the getter is called
// several times on Safari, due to WebKit bug 132872
let prop = Object.getOwnPropertyDescriptor(this, "regexpString");
if (prop)
return prop.value;
- let regexp = Filter.toRegExp(this.regexpSource);
+ let regexp;
+ if (this.regexpSource.startsWith("/") && this.regexpSource.endsWith("/"))
Wladimir Palant 2016/11/08 09:56:41 This is a potentially performance-sensitive code p
Felix Dahlke 2016/11/08 15:46:36 I'm not so sure about the performance impact of th
Felix Dahlke 2016/11/08 17:28:39 Done.
+ regexp = this.regexpSource.slice(1, -1);
+ else
+ regexp = Filter.toRegExp(this.regexpSource);
Object.defineProperty(this, "regexpString", {value: regexp});
return regexp;
}
});
« no previous file with comments | « no previous file | test/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld