|
|
@ -75,14 +75,14 @@ export default function visitComponent(
|
|
|
|
const ref = node.attributes.find((a: Node) => a.type === 'Ref');
|
|
|
|
const ref = node.attributes.find((a: Node) => a.type === 'Ref');
|
|
|
|
if (ref) generator.usesRefs = true;
|
|
|
|
if (ref) generator.usesRefs = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updates: string[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
if (attributes.length || bindings.length) {
|
|
|
|
if (attributes.length || bindings.length) {
|
|
|
|
const initialProps = attributes
|
|
|
|
const initialProps = attributes
|
|
|
|
.map((attribute: Attribute) => `${attribute.name}: ${attribute.value}`);
|
|
|
|
.map((attribute: Attribute) => `${attribute.name}: ${attribute.value}`);
|
|
|
|
|
|
|
|
|
|
|
|
const initialPropString = stringifyProps(initialProps);
|
|
|
|
const initialPropString = stringifyProps(initialProps);
|
|
|
|
|
|
|
|
|
|
|
|
const updates: string[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attributes
|
|
|
|
attributes
|
|
|
|
.filter((attribute: Attribute) => attribute.dynamic)
|
|
|
|
.filter((attribute: Attribute) => attribute.dynamic)
|
|
|
|
.forEach((attribute: Attribute) => {
|
|
|
|
.forEach((attribute: Attribute) => {
|
|
|
@ -202,15 +202,6 @@ export default function visitComponent(
|
|
|
|
} else if (initialProps.length) {
|
|
|
|
} else if (initialProps.length) {
|
|
|
|
componentInitProperties.push(`data: ${initialPropString}`);
|
|
|
|
componentInitProperties.push(`data: ${initialPropString}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (updates.length) {
|
|
|
|
|
|
|
|
block.builders.update.addBlock(deindent`
|
|
|
|
|
|
|
|
var ${name}_changes = {};
|
|
|
|
|
|
|
|
${updates.join('\n')}
|
|
|
|
|
|
|
|
${name}._set(${name}_changes);
|
|
|
|
|
|
|
|
${bindings.length && `${name_updating} = {};`}
|
|
|
|
|
|
|
|
`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const isSwitch = node.name === ':Switch';
|
|
|
|
const isSwitch = node.name === ':Switch';
|
|
|
@ -303,11 +294,20 @@ export default function visitComponent(
|
|
|
|
else if (#component.refs.${ref.name} === ${name}) {
|
|
|
|
else if (#component.refs.${ref.name} === ${name}) {
|
|
|
|
#component.refs.${ref.name} = null;
|
|
|
|
#component.refs.${ref.name} = null;
|
|
|
|
}`}
|
|
|
|
}`}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// normal update
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updates.length) {
|
|
|
|
|
|
|
|
block.builders.update.addBlock(deindent`
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
var ${name}_changes = {};
|
|
|
|
|
|
|
|
${updates.join('\n')}
|
|
|
|
|
|
|
|
${name}._set(${name}_changes);
|
|
|
|
|
|
|
|
${bindings.length && `${name_updating} = {};`}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!state.parentNode) block.builders.unmount.addLine(`if (${name}) ${name}._unmount();`);
|
|
|
|
if (!state.parentNode) block.builders.unmount.addLine(`if (${name}) ${name}._unmount();`);
|
|
|
|
|
|
|
|
|
|
|
|
block.builders.destroy.addLine(`if (${name}) ${name}.destroy(false);`);
|
|
|
|
block.builders.destroy.addLine(`if (${name}) ${name}.destroy(false);`);
|
|
|
@ -339,6 +339,15 @@ export default function visitComponent(
|
|
|
|
`${name}._mount(${state.parentNode || '#target'}, ${state.parentNode ? 'null' : 'anchor'});`
|
|
|
|
`${name}._mount(${state.parentNode || '#target'}, ${state.parentNode ? 'null' : 'anchor'});`
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updates.length) {
|
|
|
|
|
|
|
|
block.builders.update.addBlock(deindent`
|
|
|
|
|
|
|
|
var ${name}_changes = {};
|
|
|
|
|
|
|
|
${updates.join('\n')}
|
|
|
|
|
|
|
|
${name}._set(${name}_changes);
|
|
|
|
|
|
|
|
${bindings.length && `${name_updating} = {};`}
|
|
|
|
|
|
|
|
`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!state.parentNode) block.builders.unmount.addLine(`${name}._unmount();`);
|
|
|
|
if (!state.parentNode) block.builders.unmount.addLine(`${name}._unmount();`);
|
|
|
|
|
|
|
|
|
|
|
|
block.builders.destroy.addLine(deindent`
|
|
|
|
block.builders.destroy.addLine(deindent`
|
|
|
|