pull/15538/head
Rich Harris 4 months ago
parent 1e6d85b58e
commit f677792666

@ -22,25 +22,30 @@ function build(item) {
case 'element': { case 'element': {
const element = b.object([b.prop('init', b.id('e'), b.literal(item.name))]); const element = b.object([b.prop('init', b.id('e'), b.literal(item.name))]);
const entries = Object.entries(item.attributes); if (item.attributes.is) {
if (entries.length > 0) { element.properties.push(b.prop('init', b.id('is'), b.literal(item.attributes.is)));
element.properties.push( }
const attributes = b.prop('init', b.id('p'), b.object([]));
for (const key in item.attributes) {
if (key === 'is') continue;
const value = item.attributes[key];
attributes.value.properties.push(
b.prop( b.prop(
'init', 'init',
b.id('p'), b.key(fix_attribute_casing(key)),
b.object( value === undefined ? b.void0 : b.literal(value)
entries.map(([key, value]) => {
return b.prop(
'init',
b.key(fix_attribute_casing(key)),
value === undefined ? b.void0 : b.literal(value)
);
})
)
) )
); );
} }
if (attributes.value.properties.length > 0) {
element.properties.push(attributes);
}
if (item.children.length > 0) { if (item.children.length > 0) {
const children = item.children.map(build); const children = item.children.map(build);
element.properties.push(b.prop('init', b.id('c'), b.array(children))); element.properties.push(b.prop('init', b.id('c'), b.array(children)));

Loading…
Cancel
Save