Sha256: b86d142f61a901498de18780aa92503d1c550ac3cd99a44e106be328db2602c5
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 KB
Contents
/** @module ember */ /** A Glimmer2 AST transformation that replaces all instances of ```handlebars <button {{action 'foo'}}> <button onblur={{action 'foo'}}> <button onblur={{action (action 'foo') 'bar'}}> ``` with ```handlebars <button {{action this 'foo'}}> <button onblur={{action this 'foo'}}> <button onblur={{action this (action this 'foo') 'bar'}}> ``` @private @class TransformActionSyntax */ export default function transformActionSyntax({ syntax }) { let { builders: b } = syntax; return { name: 'transform-action-syntax', visitor: { ElementModifierStatement(node) { if (isAction(node)) { insertThisAsFirstParam(node, b); } }, MustacheStatement(node) { if (isAction(node)) { insertThisAsFirstParam(node, b); } }, SubExpression(node) { if (isAction(node)) { insertThisAsFirstParam(node, b); } }, }, }; } function isAction(node) { return node.path.original === 'action'; } function insertThisAsFirstParam(node, builders) { node.params.unshift(builders.path('this')); }
Version data entries
3 entries across 3 versions & 1 rubygems