Sha256: 3ed585728b3c6d4a5374c044352c1267e6b6aa5da3dd8000943d641737d09831

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

import { EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION } from '@ember/canary-features';
import { assert } from '@ember/debug';
import calculateLocationDisplay from '../system/calculate-location-display';
export default function assertSplattributeExpressions(env) {
    let { moduleName } = env.meta;
    return {
        name: 'assert-splattribute-expressions',
        visitor: {
            AttrNode({ name, loc }) {
                if (!EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION && name === '...attributes') {
                    assert(`${errorMessage()} ${calculateLocationDisplay(moduleName, loc)}`);
                }
            },
            PathExpression({ original, loc }) {
                if (original === '...attributes') {
                    assert(`${errorMessage()} ${calculateLocationDisplay(moduleName, loc)}`);
                }
            },
        },
    };
}
function errorMessage() {
    if (EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {
        return `Using "...attributes" can only be used in the element position e.g. <div ...attributes />. It cannot be used as a path.`;
    }
    return `...attributes is an invalid path`;
}

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/assert-splattribute-expression.js
discourse-ember-source-3.5.1.1 dist/es/ember-template-compiler/lib/plugins/assert-splattribute-expression.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-template-compiler/lib/plugins/assert-splattribute-expression.js