Skip to content

Commit

Permalink
Convert class based template compilation plugin to functional style
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed May 6, 2021
1 parent fc27e64 commit 84640e4
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions strip-test-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,26 @@ function stripTestSelectors(node) {
});
}

function StripTestSelectorsTransform() {
this.syntax = null;
function transform() {
return {
name: 'strip-test-selectors',

visitor: {
ElementNode(node) {
node.attributes = node.attributes.filter(function(attribute) {
return !isTestSelector(attribute.name);
});
},

MustacheStatement(node) {
stripTestSelectors(node);
},

BlockStatement(node) {
stripTestSelectors(node);
},
}
};
}

StripTestSelectorsTransform.prototype.transform = function(ast) {
let { traverse } = this.syntax;

traverse(ast, {
ElementNode(node) {
node.attributes = node.attributes.filter(function(attribute) {
return !isTestSelector(attribute.name);
});
},

MustacheStatement(node) {
stripTestSelectors(node);
},

BlockStatement(node) {
stripTestSelectors(node);
},
});

return ast;
};

module.exports = StripTestSelectorsTransform;
module.exports = transform;

0 comments on commit 84640e4

Please sign in to comment.