Sha256: b5a804174d8ff84b7c2ab2cad2ff9c0185e4905d829da5cd48c3a2990ffb1871

Contents?: true

Size: 987 Bytes

Versions: 3

Compression:

Stored size: 987 Bytes

Contents

export default function transformQuotedBindingsIntoJustBindings( /* env */) {
    return {
        name: 'transform-quoted-bindings-into-just-bindings',
        visitor: {
            ElementNode(node) {
                let styleAttr = getStyleAttr(node);
                if (!validStyleAttr(styleAttr)) {
                    return;
                }
                styleAttr.value = styleAttr.value.parts[0];
            },
        },
    };
}
function validStyleAttr(attr) {
    if (!attr) {
        return false;
    }
    let value = attr.value;
    if (!value || value.type !== 'ConcatStatement' || value.parts.length !== 1) {
        return false;
    }
    let onlyPart = value.parts[0];
    return onlyPart.type === 'MustacheStatement';
}
function getStyleAttr(node) {
    let attributes = node.attributes;
    for (let i = 0; i < attributes.length; i++) {
        if (attributes[i].name === 'style') {
            return attributes[i];
        }
    }
    return undefined;
}

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/transform-quoted-bindings-into-just-bindings.js
discourse-ember-source-3.5.1.1 dist/es/ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.js