Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion examples/example.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,22 @@ button

button
border-radius: 0
width: 100%
width: 100%

@custom-selector --heading h1, h2
@custom-selector :--link :hover, :active

@custom-selector --heading h1, h2
@custom-selector :--any-link :link, :visited

a:hover
color: red

a:--any-link
color: blue

--heading
color: #fff

article --heading
color: #000
2 changes: 1 addition & 1 deletion examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ var fs = require('fs')

var str = read('examples/example.css', 'utf8');
var css = compile(str);
console.log(css);
console.log(css);
5 changes: 3 additions & 2 deletions lib/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ var pseudos = [
'-o',
'-ms',
'-moz',
'-webkit'
'-webkit',
'--'
]

/**
Expand Down Expand Up @@ -196,7 +197,7 @@ module.exports = function(str) {
var m = str.match(/^([^\n,]+, *\n|[^\n]+)+/);
if (!m) return;
str = str.slice(m[0].length);
m = m[0].split(/\s*,\s*/);
m = (m[0].indexOf('@custom-selector') > -1) ? [m[0]] : m[0].split(/\s*,\s*/);
return ['rule', m];
}
}
11 changes: 11 additions & 0 deletions test/cases/custom-selectors.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@custom-selector --heading h1, h2
@custom-selector :--any-link :link, :visited

a:--any-link
color: blue

--heading
color: #fff

article --heading
color: #000
15 changes: 15 additions & 0 deletions test/cases/custom-selectors.out.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@custom-selector --heading h1, h2;

@custom-selector :--any-link :link, :visited;

a:--any-link {
color: blue;
}

--heading {
color: #fff;
}

article --heading {
color: #000;
}