[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 25/483: Improve translating of id and class attribute rules
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:41:23 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus-element-hiding-helper.
commit b247405021452a40d03b21ad4f3f61208d98e822
Author: Wladimir Palant <trev at gtchat.de>
Date: Wed Jan 10 16:03:43 2007 +0000
Improve translating of id and class attribute rules
--HG--
extra : convert_revision : svn%3Ad8bf93c1-8190-44a8-bb31-1ea94378a4df/trunk%40622
---
chrome/content/composer.js | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/chrome/content/composer.js b/chrome/content/composer.js
index 2534a8f..48233a9 100644
--- a/chrome/content/composer.js
+++ b/chrome/content/composer.js
@@ -210,10 +210,23 @@ function updateExpression() {
if (expressionSimple != null)
expressionSimple += "(" + attr.name + op + attr.value + ")";
- var escapedValue = attr.value.replace(/"/g, '\\"')
- .replace(/\{/, "\\7B ")
- .replace(/\}/, "\\7D ");
- expressionRaw += "[" + escapedName + op + '"' + escapedValue + '"' + "]";
+ if (attr.name == "id" && op == "=" && !/[^\w\-]/.test(attr.value))
+ expressionRaw += "#" + attr.value;
+ else if (attr.name == "class" && op == "=" && !/[^\w\-\s]/.test(attr.value) && /\S/.test(attr.value)) {
+ var classes = attr.value.split(/\s+/);
+ for (var j = 0; j < classes.length; j++) {
+ if (classes[j] == "")
+ continue;
+
+ expressionRaw += "." + classes[j];
+ }
+ }
+ else {
+ var escapedValue = attr.value.replace(/"/g, '\\"')
+ .replace(/\{/, "\\7B ")
+ .replace(/\}/, "\\7D ");
+ expressionRaw += "[" + escapedName + op + '"' + escapedValue + '"' + "]";
+ }
}
else {
expressionSimple = null;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git
More information about the Pkg-mozext-commits
mailing list