From aa21cdf9c3ef6c2bfe529796687049bfbef5f1a9 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Thu, 3 May 2018 09:51:57 +0200 Subject: [PATCH] Process also shallow children and not only nested --- src/components/select/select.vue | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index f3258af..5c666f9 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -107,6 +107,19 @@ return options.concat(findOptionsInVNode(slotEntry)); }, []); + const applyProp = (node, propName, value) => { + return { + ...node, + componentOptions: { + ...node.componentOptions, + propsData: { + ...node.componentOptions.propsData, + [propName]: value, + } + } + }; + }; + export default { name: 'iSelect', mixins: [ Emitter, Locale ], @@ -304,19 +317,13 @@ const autoCompleteOptions = extractOptions(slotOptions); const selectedSlotOption = autoCompleteOptions[currentIndex]; - return slotOptions.map(node => copyChildren(node, (child) => { - if (child !== selectedSlotOption) return child; - return { - ...child, - componentOptions: { - ...child.componentOptions, - propsData: { - ...child.componentOptions.propsData, - isFocused: true, - } - } - }; - })); + return slotOptions.map(node => { + if (node === selectedSlotOption) return applyProp(node, 'isFocused', true); + return copyChildren(node, (child) => { + if (child !== selectedSlotOption) return child; + return applyProp(child, 'isFocused', true); + }); + }); } for (let option of slotOptions) { -- libgit2 0.21.4