|
|
|
|
@ -6,7 +6,7 @@ import { is_ignored } from '../../../../../state.js';
|
|
|
|
|
import { is_event_attribute } from '../../../../../utils/ast.js';
|
|
|
|
|
import * as b from '../../../../../utils/builders.js';
|
|
|
|
|
import { build_getter, create_derived } from '../../utils.js';
|
|
|
|
|
import { build_template_chunk } from './utils.js';
|
|
|
|
|
import { build_template_chunk, get_expression_id } from './utils.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {Array<AST.Attribute | AST.SpreadAttribute>} attributes
|
|
|
|
|
@ -104,20 +104,13 @@ export function build_style_directives(
|
|
|
|
|
const state = context.state;
|
|
|
|
|
|
|
|
|
|
for (const directive of style_directives) {
|
|
|
|
|
const { has_state, has_call } = directive.metadata.expression;
|
|
|
|
|
const { has_state } = directive.metadata.expression;
|
|
|
|
|
|
|
|
|
|
let value =
|
|
|
|
|
directive.value === true
|
|
|
|
|
? build_getter({ name: directive.name, type: 'Identifier' }, context.state)
|
|
|
|
|
: build_attribute_value(directive.value, context);
|
|
|
|
|
|
|
|
|
|
if (has_call) {
|
|
|
|
|
const id = b.id(state.scope.generate('style_directive'));
|
|
|
|
|
|
|
|
|
|
state.init.push(b.const(id, create_derived(state, b.thunk(value))));
|
|
|
|
|
value = b.call('$.get', id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const update = b.stmt(
|
|
|
|
|
b.call(
|
|
|
|
|
'$.set_style',
|
|
|
|
|
@ -156,10 +149,7 @@ export function build_class_directives(
|
|
|
|
|
let value = /** @type {Expression} */ (context.visit(directive.expression));
|
|
|
|
|
|
|
|
|
|
if (has_call) {
|
|
|
|
|
const id = b.id(state.scope.generate('class_directive'));
|
|
|
|
|
|
|
|
|
|
state.init.push(b.const(id, create_derived(state, b.thunk(value))));
|
|
|
|
|
value = b.call('$.get', id);
|
|
|
|
|
value = get_expression_id(state, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const update = b.stmt(b.call('$.toggle_class', element_id, b.literal(directive.name), value));
|
|
|
|
|
|