Skip to content

Commit

Permalink
Adding grouping for classname so we don't have to trim the boundary c…
Browse files Browse the repository at this point in the history
…har later
  • Loading branch information
src-code committed Jul 13, 2015
1 parent 9bc3407 commit 5ad204c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/atomizer.js
Expand Up @@ -86,7 +86,7 @@ Atomizer.prototype.findClassNames = function (src/*:string*/)/*:string[]*/ {

while (match !== null) {
// strip boundary character
className = match[0].trim();
className = match[1];

// assign to classNamesObj as key and give it a counter
classNamesObj[className] = (classNamesObj[className] || 0) + 1;
Expand Down Expand Up @@ -183,7 +183,7 @@ Atomizer.prototype.parseConfig = function (config/*:AtomizerConfig*/, options/*:
rule = this.rules[ruleIndex];

treeo = {
className: match[0],
className: match[1],
declarations: _.cloneDeep(rule.styles)
};

Expand Down
4 changes: 3 additions & 1 deletion src/lib/grammar.js
Expand Up @@ -181,6 +181,7 @@ Grammar.prototype.getSyntax = function getSyntax(isSimple)/*:string*/ {
var syntax = [
// word boundary
GRAMMAR.BOUNDARY,
'(',
// optional parent
'(?<parentSelector>',
isSimple ? GRAMMAR.PARENT_SELECTOR_SIMPLE : GRAMMAR.PARENT_SELECTOR,
Expand All @@ -197,7 +198,8 @@ Grammar.prototype.getSyntax = function getSyntax(isSimple)/*:string*/ {
// optional modifier
'(?:',
GRAMMAR.BREAKPOINT,
')?'
')?',
')'
].join('');

return XRegExp(syntax, 'g');
Expand Down

0 comments on commit 5ad204c

Please sign in to comment.