Skip to content

Commit f677792

Browse files
committed
fix
1 parent 1e6d85b commit f677792

File tree

1 file changed

+18
-13
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client/transform-template

1 file changed

+18
-13
lines changed

packages/svelte/src/compiler/phases/3-transform/client/transform-template/to-functions.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,30 @@ function build(item) {
2222
case 'element': {
2323
const element = b.object([b.prop('init', b.id('e'), b.literal(item.name))]);
2424

25-
const entries = Object.entries(item.attributes);
26-
if (entries.length > 0) {
27-
element.properties.push(
25+
if (item.attributes.is) {
26+
element.properties.push(b.prop('init', b.id('is'), b.literal(item.attributes.is)));
27+
}
28+
29+
const attributes = b.prop('init', b.id('p'), b.object([]));
30+
31+
for (const key in item.attributes) {
32+
if (key === 'is') continue;
33+
34+
const value = item.attributes[key];
35+
36+
attributes.value.properties.push(
2837
b.prop(
2938
'init',
30-
b.id('p'),
31-
b.object(
32-
entries.map(([key, value]) => {
33-
return b.prop(
34-
'init',
35-
b.key(fix_attribute_casing(key)),
36-
value === undefined ? b.void0 : b.literal(value)
37-
);
38-
})
39-
)
39+
b.key(fix_attribute_casing(key)),
40+
value === undefined ? b.void0 : b.literal(value)
4041
)
4142
);
4243
}
4344

45+
if (attributes.value.properties.length > 0) {
46+
element.properties.push(attributes);
47+
}
48+
4449
if (item.children.length > 0) {
4550
const children = item.children.map(build);
4651
element.properties.push(b.prop('init', b.id('c'), b.array(children)));

0 commit comments

Comments
 (0)