Skip to content

Commit 45522fc

Browse files
committed
fix: fix expandProps when position is not allowed
Also fix option in website.
1 parent 169eb2f commit 45522fc

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

packages/core/src/h2x/expandProps.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ const expandProps = (position = 'end') => () => ({
1212
props.name = 'props'
1313
props.spread = true
1414
if (position === 'start') {
15-
path.node.attributes.unshift(props)
15+
path.node.attributes = [props, ...path.node.attributes]
16+
path.replace(path.node)
1617
}
1718
if (position === 'end') {
18-
path.node.attributes.push(props)
19+
path.node.attributes = [...path.node.attributes, props]
20+
path.replace(path.node)
1921
}
20-
path.replace(path.node)
2122
}
2223
},
2324
},

website/config/settings.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ export const settings = [
2424
group: 'global',
2525
default: false,
2626
},
27-
{
28-
label: 'Expand props',
29-
name: 'expandProps',
30-
type: 'boolean',
31-
group: 'global',
32-
default: true,
33-
},
3427
{
3528
label: 'Ref',
3629
name: 'ref',
@@ -45,6 +38,15 @@ export const settings = [
4538
group: 'global',
4639
default: false,
4740
},
41+
{
42+
label: 'Expand props',
43+
name: 'expandProps',
44+
type: 'enum',
45+
values: ['start', 'end', 'none'],
46+
group: 'global',
47+
default: 'end',
48+
transform: value => value === 'none' ? false : value,
49+
},
4850
{
4951
label: 'Replace attributes value',
5052
name: 'replaceAttrValues',

0 commit comments

Comments
 (0)