pull/15844/head
Rich Harris 3 months ago
parent d7a99b6548
commit 650144aa75

@ -1,4 +1,4 @@
/** @import { ArrayExpression, Expression, ExpressionStatement, Identifier, MemberExpression, ObjectExpression } from 'estree' */ /** @import { ArrayExpression, Expression, ExpressionStatement, Identifier, MemberExpression, ObjectExpression, Property } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentClientTransformState, ComponentContext, MemoizedExpression } from '../types' */ /** @import { ComponentClientTransformState, ComponentContext, MemoizedExpression } from '../types' */
/** @import { Scope } from '../../../scope' */ /** @import { Scope } from '../../../scope' */
@ -504,8 +504,9 @@ export function build_style_directives_object(
async_expressions = context.state.async_expressions, async_expressions = context.state.async_expressions,
expressions = context.state.expressions expressions = context.state.expressions
) { ) {
let normal_properties = []; const normal = b.object([]);
let important_properties = []; const important = b.object([]);
let has_call_or_state = false; let has_call_or_state = false;
let has_await = false; let has_await = false;
@ -514,21 +515,15 @@ export function build_style_directives_object(
d.value === true d.value === true
? build_getter({ name: d.name, type: 'Identifier' }, context.state) ? build_getter({ name: d.name, type: 'Identifier' }, context.state)
: build_attribute_value(d.value, context).value; : build_attribute_value(d.value, context).value;
const property = b.init(d.name, expression);
if (d.modifiers.includes('important')) { const object = d.modifiers.includes('important') ? important : normal;
important_properties.push(property); object.properties.push(b.init(d.name, expression));
} else {
normal_properties.push(property);
}
has_call_or_state ||= d.metadata.expression.has_call || d.metadata.expression.has_state; has_call_or_state ||= d.metadata.expression.has_call || d.metadata.expression.has_state;
has_await ||= d.metadata.expression.has_await; has_await ||= d.metadata.expression.has_await;
} }
const directives = important_properties.length const directives = important.properties.length ? b.array([normal, important]) : normal;
? b.array([b.object(normal_properties), b.object(important_properties)])
: b.object(normal_properties);
return has_call_or_state || has_await return has_call_or_state || has_await
? get_expression_id(has_await ? async_expressions : expressions, directives) ? get_expression_id(has_await ? async_expressions : expressions, directives)

Loading…
Cancel
Save