pull/4749/head
Timothy Johnson 6 years ago
parent 4e19bac21e
commit f1358da4be

@ -152,7 +152,7 @@ export default class InlineComponentWrapper extends Wrapper {
const uses_spread = !!this.node.attributes.find(a => a.is_spread); const uses_spread = !!this.node.attributes.find(a => a.is_spread);
const uses_classes = this.node.classes.length > 0 const uses_classes = this.node.classes.length > 0;
const classNames: Identifier = { const classNames: Identifier = {
type: 'Identifier', type: 'Identifier',
@ -182,7 +182,7 @@ export default class InlineComponentWrapper extends Wrapper {
const attributes = uses_classes const attributes = uses_classes
? this.node.attributes.filter(a => a.name !== 'class') ? this.node.attributes.filter(a => a.name !== 'class')
: this.node.attributes : this.node.attributes;
const attribute_object = uses_spread const attribute_object = uses_spread
? x`{ ${initial_props} }` ? x`{ ${initial_props} }`
@ -341,10 +341,10 @@ export default class InlineComponentWrapper extends Wrapper {
if (attribute) { if (attribute) {
const dependencies = attribute.get_dependencies(); const dependencies = attribute.get_dependencies();
const condition = block.renderer.dirty(Array.from(dependencies)); const condition = block.renderer.dirty(Array.from(dependencies));
const value = attribute.get_value(block) const value = attribute.get_value(block);
updates.push(b`if (${condition}) { updates.push(b`if (${condition}) {
${classNames}.$$class = ${value}; ${classNames}.$$class = ${value};
}`) }`);
all_dependencies.push(...dependencies); all_dependencies.push(...dependencies);
initial_class_values.push(p`$$class: ${value}`); initial_class_values.push(p`$$class: ${value}`);

@ -35,12 +35,17 @@ export default function(node: InlineComponent, renderer: Renderer, options: Rend
let props; let props;
let attributes = node.attributes let attributes = node.attributes;
let classProp let classProp;
if (node.classes.length > 0) { if (node.classes.length > 0) {
const index = attributes.findIndex(a => a.name === 'class') let attr;
const attr = attributes[index] attributes = attributes.filter(a => {
attributes.splice(index, 1) if (a.name === 'class') {
attr = a;
return false;
}
return true;
});
classProp = p` classProp = p`
class: @component_classnames({ class: @component_classnames({
${node.classes.map(class_directive => { ${node.classes.map(class_directive => {
@ -50,7 +55,7 @@ export default function(node: InlineComponent, renderer: Renderer, options: Rend
})}, })},
${attr ? p`$$class: ${get_prop_value(attr)}` : null} ${attr ? p`$$class: ${get_prop_value(attr)}` : null}
}) })
` `;
} }
if (uses_spread) { if (uses_spread) {

Loading…
Cancel
Save