8000 Allow prefixes to be empty... by jangarcia · Pull Request #1990 · stylus/stylus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow prefixes to be empty... #1990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
Open
6 changes: 3 additions & 3 deletions lib/visitor/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var Evaluator = module.exports = function Evaluator(root, options) {
this.imports = options.imports || [];
this.globals = options.globals || {};
this.paths = options.paths || [];
this.prefix = options.prefix || '';
this.prefix = options.prefix || null;
this.filename = options.filename;
this.includeCSS = options['include css'];
this.resolveURL = functions.url
Expand Down Expand Up @@ -1417,8 +1417,8 @@ Evaluator.prototype.interpolate = function(node){
return node.name;
case 'literal':
case 'string':
if (self.prefix && !node.prefixed && !node.val.nodeName) {
node.val = node.val.replace(/\./g, '.' + self.prefix);
if (self.prefix !== null && !node.prefixed && !node.val.nodeName) {
node.val = node.val.replace(/\.(?=[\w-])|^\.$/g, '.' + self.prefix);
node.prefixed = true;
}
return node.val;
Expand Down
36 changes: 36 additions & 0 deletions test/cases/bifs.prefix-classes.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@
.prefix-test2 {
width: 1px;
}
.outer-prefix-test {
width: 1px;
}
.outer-prefix-test2 {
width: 1px;
}
.outer-prefix-test2 .test3 {
width: 1px;
}
.outer-prefix-test2 .test4 {
width: 1px;
}
.outer-prefix-test2 .test4 .other-prefix-test5 {
width: 1px;
}
.outer-prefix-test2 .test4 .other-prefix-test6 {
width: 1px;
}
.test7 {
width: 1px;
}
.test8 {
width: 1px;
}
.prefix-test {
width: 1px;
}
.prefix-test .prefix-test2 {
width: 1px;
}
.prefix-test .prefix-test3 {
color: #00f;
}
.prefix-test2 .prefix-test4 .prefix-test6 {
color: #008000;
}
.bar {
width: 10px;
}
Expand Down
33 changes: 33 additions & 0 deletions test/cases/bifs.prefix-classes.styl
< 4BC3 td class="blob-code blob-code-addition js-file-line"> color: green
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,39 @@ foo()
.test2
width: 1px

+prefix-classes('outer-prefix-')
.test
width: 1px
.test2
width: 1px
+prefix-classes('')
.test3
width: 1px
.test4
width: 1px
+prefix-classes('other-prefix-')
.test5
width: 1px
.test6
width: 1px
+prefix-classes('')
.test7
width: 1px
.test8
width: 1px

+prefix-classes('prefix-')
.test
width: 1px
.test2
width: 1px
../ .test3
color: blue
.test4
.test5
^[1..-2] .test6

+foo()
width: 10px
+prefix-classes('prefix2-')
Expand Down
0