Skip to content

Commit

Permalink
add atrule walk context (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Mar 14, 2017
1 parent 0faab2b commit b9f6733
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/syntax/node/Atrule.js
Expand Up @@ -93,5 +93,6 @@ module.exports = {
result.push(node.block ? this.generate(node.block) : ';');

return result;
}
},
walkContext: 'atrule'
};
16 changes: 16 additions & 0 deletions lib/walker/index.js
Expand Up @@ -13,7 +13,12 @@ function walkRules(node, item, list) {

case 'Atrule':
if (node.block !== null) {
var oldAtrule = this.atrule;
this.atrule = node;

walkRules.call(this, node.block);

this.atrule = oldAtrule;
}

this.fn(node, item, list);
Expand Down Expand Up @@ -54,7 +59,12 @@ function walkRulesRight(node, item, list) {

case 'Atrule':
if (node.block !== null) {
var oldAtrule = this.atrule;
this.atrule = node;

walkRulesRight.call(this, node.block);

this.atrule = oldAtrule;
}

this.fn(node, item, list);
Expand Down Expand Up @@ -95,7 +105,12 @@ function walkDeclarations(node) {

case 'Atrule':
if (node.block !== null) {
var oldAtrule = this.atrule;
this.atrule = node;

walkDeclarations.call(this, node.block);

this.atrule = oldAtrule;
}
break;

Expand Down Expand Up @@ -127,6 +142,7 @@ function createContext(root, fn) {
fn: fn,
root: root,
stylesheet: null,
atrule: null,
atruleExpression: null,
rule: null,
selector: null,
Expand Down

0 comments on commit b9f6733

Please sign in to comment.