From 45522fc421bf9e1f91a74b1a9af6e466c11845b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Sun, 30 Sep 2018 21:11:39 +0200 Subject: [PATCH] fix: fix expandProps when position is not allowed Also fix option in website. --- packages/core/src/h2x/expandProps.js | 7 ++++--- website/config/settings.js | 16 +++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/core/src/h2x/expandProps.js b/packages/core/src/h2x/expandProps.js index 11e26d4b..527b9ab9 100644 --- a/packages/core/src/h2x/expandProps.js +++ b/packages/core/src/h2x/expandProps.js @@ -12,12 +12,13 @@ const expandProps = (position = 'end') => () => ({ props.name = 'props' props.spread = true if (position === 'start') { - path.node.attributes.unshift(props) + path.node.attributes = [props, ...path.node.attributes] + path.replace(path.node) } if (position === 'end') { - path.node.attributes.push(props) + path.node.attributes = [...path.node.attributes, props] + path.replace(path.node) } - path.replace(path.node) } }, }, diff --git a/website/config/settings.js b/website/config/settings.js index bb15942c..9384005b 100644 --- a/website/config/settings.js +++ b/website/config/settings.js @@ -24,13 +24,6 @@ export const settings = [ group: 'global', default: false, }, - { - label: 'Expand props', - name: 'expandProps', - type: 'boolean', - group: 'global', - default: true, - }, { label: 'Ref', name: 'ref', @@ -45,6 +38,15 @@ export const settings = [ group: 'global', default: false, }, + { + label: 'Expand props', + name: 'expandProps', + type: 'enum', + values: ['start', 'end', 'none'], + group: 'global', + default: 'end', + transform: value => value === 'none' ? false : value, + }, { label: 'Replace attributes value', name: 'replaceAttrValues',