Sha256: 40ad1ec6ad845ba3bff2006de05f6e4a247d4492f08b81dec8a3921d814854cd

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

import { deprecate } from '@ember/debug';
import { SEND_ACTION } from '@ember/deprecated-features';
import calculateLocationDisplay from '../system/calculate-location-display';
const EVENTS = [
    'insert-newline',
    'enter',
    'escape-press',
    'focus-in',
    'focus-out',
    'key-press',
    'key-up',
    'key-down',
];
export default function deprecateSendAction(env) {
    if (SEND_ACTION) {
        let { moduleName } = env.meta;
        let deprecationMessage = (node, evName, action) => {
            let sourceInformation = calculateLocationDisplay(moduleName, node.loc);
            return `Please refactor \`{{input ${evName}="${action}"}}\` to \`{{input ${evName}=(action "${action}")}}\. ${sourceInformation}`;
        };
        return {
            name: 'deprecate-send-action',
            visitor: {
                MustacheStatement(node) {
                    if (node.path.original !== 'input') {
                        return;
                    }
                    node.hash.pairs.forEach(pair => {
                        if (EVENTS.indexOf(pair.key) > -1 && pair.value.type === 'StringLiteral') {
                            deprecate(deprecationMessage(node, pair.key, pair.value.original), false, {
                                id: 'ember-component.send-action',
                                until: '4.0.0',
                                url: 'https://emberjs.com/deprecations/v3.x#toc_ember-component-send-action',
                            });
                        }
                    });
                },
            },
        };
    }
    return;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/ember-template-compiler/lib/plugins/deprecate-send-action.js
discourse-ember-source-3.5.1.1 dist/es/ember-template-compiler/lib/plugins/deprecate-send-action.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-template-compiler/lib/plugins/deprecate-send-action.js