From ceea32dc631efab5c5b00722ec331f16a1751a4e Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 6 May 2021 16:09:26 +0200 Subject: [PATCH] Use `traverse()` instead of the deprecated `Walker` class --- strip-test-selectors.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/strip-test-selectors.js b/strip-test-selectors.js index b1d9d762..220a19e7 100644 --- a/strip-test-selectors.js +++ b/strip-test-selectors.js @@ -27,16 +27,22 @@ function StripTestSelectorsTransform() { } StripTestSelectorsTransform.prototype.transform = function(ast) { - let walker = new this.syntax.Walker(); + let { traverse } = this.syntax; - walker.visit(ast, function(node) { - if (node.type === 'ElementNode') { + traverse(ast, { + ElementNode(node) { node.attributes = node.attributes.filter(function(attribute) { return !isTestSelector(attribute.name); }); - } else if (node.type === 'MustacheStatement' || node.type === 'BlockStatement') { + }, + + MustacheStatement(node) { + stripTestSelectors(node); + }, + + BlockStatement(node) { stripTestSelectors(node); - } + }, }); return ast;