Index: chrome/content/cssProperties.js |
=================================================================== |
--- a/chrome/content/cssProperties.js |
+++ b/chrome/content/cssProperties.js |
@@ -1,8 +1,45 @@ |
+function splitSelector(selector) |
Sebastian Noack
2016/02/15 17:19:08
This logic has been copied (with some minor change
kzar
2016/02/15 17:30:14
Acknowledged. (Mind filing an issue for that?)
Sebastian Noack
2016/02/15 17:49:31
I attached the patch the same issue: https://coder
|
+{ |
+ if (selector.indexOf(",") == -1) |
+ return [selector]; |
+ |
+ var selectors = []; |
+ var start = 0; |
+ var level = 0; |
+ var sep = ""; |
+ |
+ for (var i = 0; i < selector.length; i++) |
+ { |
+ var chr = selector[i]; |
+ |
+ if (chr == "\\") // ignore escaped characters |
+ i++; |
+ else if (chr == sep) // don't split within quoted text |
+ sep = ""; // e.g. [attr=","] |
+ else if (sep == "") |
+ { |
+ if (chr == '"' || chr == "'") |
+ sep = chr; |
+ else if (chr == "(") // don't split between parentheses |
+ level++; // e.g. :matches(div,span) |
+ else if (chr == ")") |
+ level = Math.max(0, level - 1); |
+ else if (chr == "," && level == 0) |
+ { |
+ selectors.push(selector.substring(start, i)); |
+ start = i + 1; |
+ } |
+ } |
+ } |
+ |
+ selectors.push(selector.substring(start)); |
+ return selectors; |
+} |
+ |
function CSSPropertyFilters(window, addSelectorsFunc) { |
this.window = window; |
this.addSelectorsFunc = addSelectorsFunc; |
} |
- |
CSSPropertyFilters.prototype = { |
stringifyStyle: function(style) |
{ |
@@ -40,7 +77,11 @@ |
regexp = pattern.regexp = new RegExp(regexp); |
if (regexp.test(style)) |
- selectors.push(pattern.prefix + rule.selectorText + pattern.suffix); |
+ { |
+ var subSelectors = splitSelector(rule.selectorText); |
+ for (var k = 0; k < subSelectors.length; k++) |
+ selectors.push(pattern.prefix + subSelectors[k] + pattern.suffix); |
+ } |
} |
} |
}, |