diff --git a/src/compiler/compile/utils/get_slot_data.js b/src/compiler/compile/utils/get_slot_data.js index b0cdd30cde..6d5593f654 100644 --- a/src/compiler/compile/utils/get_slot_data.js +++ b/src/compiler/compile/utils/get_slot_data.js @@ -6,22 +6,22 @@ import { string_literal } from './stringify.js'; * @param {Block} block */ export default function get_slot_data(values, block = null) { - return { - type: 'ObjectExpression', - properties: Array.from(values.values()) - .filter((attribute) => attribute.name !== 'name') - .map((attribute) => { - if (attribute.is_spread) { - const argument = get_spread_value(block, attribute); - return { - type: 'SpreadElement', - argument - }; - } - const value = get_value(block, attribute); - return p `${attribute.name}: ${value}`; - }) - }; + return { + type: 'ObjectExpression', + properties: Array.from(values.values()) + .filter((attribute) => attribute.name !== 'name') + .map((attribute) => { + if (attribute.is_spread) { + const argument = get_spread_value(block, attribute); + return { + type: 'SpreadElement', + argument + }; + } + const value = get_value(block, attribute); + return p`${attribute.name}: ${value}`; + }) + }; } /** @@ -29,21 +29,21 @@ export default function get_slot_data(values, block = null) { * @param {Attribute} attribute */ function get_value(block, attribute) { - if (attribute.is_true) - return x `true`; - if (attribute.chunks.length === 0) - return x `""`; - let value = attribute.chunks - .map((chunk) => chunk.type === 'Text' - ? string_literal(chunk.data) - : block - ? chunk.manipulate(block) - : chunk.node) - .reduce((lhs, rhs) => x `${lhs} + ${rhs}`); - if (attribute.chunks.length > 1 && attribute.chunks[0].type !== 'Text') { - value = x `"" + ${value}`; - } - return value; + if (attribute.is_true) return x`true`; + if (attribute.chunks.length === 0) return x`""`; + let value = attribute.chunks + .map((chunk) => + chunk.type === 'Text' + ? string_literal(chunk.data) + : block + ? chunk.manipulate(block) + : chunk.node + ) + .reduce((lhs, rhs) => x`${lhs} + ${rhs}`); + if (attribute.chunks.length > 1 && attribute.chunks[0].type !== 'Text') { + value = x`"" + ${value}`; + } + return value; } /** @@ -51,9 +51,5 @@ function get_value(block, attribute) { * @param {Attribute} attribute */ function get_spread_value(block, attribute) { - return block ? attribute.expression.manipulate(block) : attribute.expression.node; + return block ? attribute.expression.manipulate(block) : attribute.expression.node; } - - - -