summaryrefslogtreecommitdiff
path: root/common/modules/styles.jsm
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-06-19 10:56:16 -0400
committerKris Maglione <maglione.k@gmail.com>2011-06-19 10:56:16 -0400
commit5684be9b369b5fcf6409d0cbef793a7e84481cf5 (patch)
tree98c350887e61f74124c6ca8c00e69345732bcd8f /common/modules/styles.jsm
parentc3d5e7bb74812ac0ee980a2726ef8f8bb3633ac2 (diff)
downloadpentadactyl-5684be9b369b5fcf6409d0cbef793a7e84481cf5.tar.gz
Add support for regexp site-filters to :style.
Diffstat (limited to 'common/modules/styles.jsm')
-rw-r--r--common/modules/styles.jsm17
1 files changed, 10 insertions, 7 deletions
diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm
index 19dc8e41..2586ac83 100644
--- a/common/modules/styles.jsm
+++ b/common/modules/styles.jsm
@@ -68,17 +68,20 @@ update(Sheet.prototype, {
get fullCSS() {
let filter = this.sites;
let css = this.css;
+
+ let preamble = "/* " + this.uri + (this.agent ? " (agent)" : "") + " */\n\n" + namespace + "\n";
if (filter[0] == "*")
- return namespace + css;
+ return preamble + css;
let selectors = filter.map(function (part)
- (/[*]$/.test(part) ? "url-prefix" :
- /[\/:]/.test(part) ? "url"
- : "domain")
- + '("' + part.replace(/"/g, "%22").replace(/\*$/, "") + '")')
+ !/^(?:[a-z-]+:|[a-z-.]+$)/.test(filter) ? "regexp(" + part.quote() + ")" :
+ (/[*]$/.test(part) ? "url-prefix" :
+ /[\/:]/.test(part) ? "url"
+ : "domain")
+ + '("' + part.replace(/"/g, "%22").replace(/\*$/, "") + '")')
.join(",\n ");
- return "/* " + this.uri + (this.agent ? " (agent)" : "") + " */\n\n"
- + namespace + "\n@-moz-document " + selectors + " {\n\n" + css + "\n\n}\n";
+
+ return preamble + "@-moz-document " + selectors + " {\n\n" + css + "\n\n}\n";
}
});