[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 184/483: Better handling for elements with multiple classes: any of the classes present can be entered and will be translated into .class
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:41:39 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 3ffe9e191fc1607e8fba7294067c18cfbdec6211
Author: Wladimir Palant <trev at adblockplus.org>
Date: Thu Oct 15 15:46:31 2009 +0200
Better handling for elements with multiple classes: any of the classes present can be entered and will be translated into .class
---
chrome/content/composer.js | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/chrome/content/composer.js b/chrome/content/composer.js
index 0527cf7..189a4c0 100644
--- a/chrome/content/composer.js
+++ b/chrome/content/composer.js
@@ -210,18 +210,24 @@ function updateExpression() {
else if (attr.value.substr(attr.value.length - attr.selected.length) == attr.selected)
op = "$=";
+ let useFallback = false;
if (attr.name == "id" && op == "=" && !/[^\w\-]/.test(attr.selected))
expression += "#" + attr.selected;
- else if (attr.name == "class" && op == "=" && !/[^\w\-\s]/.test(attr.selected) && /\S/.test(attr.selected)) {
- var classes = attr.selected.split(/\s+/);
- for (var j = 0; j < classes.length; j++) {
- if (classes[j] == "")
- continue;
-
- expression += "." + classes[j];
- }
+ else if (attr.name == "class" && !/[^\w\-\s]/.test(attr.selected) && /\S/.test(attr.selected)) {
+ let knownClasses = {};
+ for each (let cls in attr.value.split(/\s+/))
+ knownClasses[cls] = true;
+
+ let classes = attr.selected.split(/\s+/).filter(function(cls) cls != "");
+ if (classes.every(function(cls) knownClasses.hasOwnProperty(cls)))
+ expression += "." + classes.join(".");
+ else
+ useFallback = true;
}
- else {
+ else
+ useFallback = true;
+
+ if (useFallback) {
var escapedValue = attr.selected.replace(/"/g, '\\"')
.replace(/\{/, "\\7B ")
.replace(/\}/, "\\7D ");
--
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