Process also shallow children and not only nested

This commit is contained in:
Sergio Crisostomo 2018-05-03 09:51:57 +02:00
parent 523e2c81fd
commit aa21cdf9c3

View file

@ -107,6 +107,19 @@
return options.concat(findOptionsInVNode(slotEntry)); return options.concat(findOptionsInVNode(slotEntry));
}, []); }, []);
const applyProp = (node, propName, value) => {
return {
...node,
componentOptions: {
...node.componentOptions,
propsData: {
...node.componentOptions.propsData,
[propName]: value,
}
}
};
};
export default { export default {
name: 'iSelect', name: 'iSelect',
mixins: [ Emitter, Locale ], mixins: [ Emitter, Locale ],
@ -304,19 +317,13 @@
const autoCompleteOptions = extractOptions(slotOptions); const autoCompleteOptions = extractOptions(slotOptions);
const selectedSlotOption = autoCompleteOptions[currentIndex]; const selectedSlotOption = autoCompleteOptions[currentIndex];
return slotOptions.map(node => copyChildren(node, (child) => { return slotOptions.map(node => {
if (node === selectedSlotOption) return applyProp(node, 'isFocused', true);
return copyChildren(node, (child) => {
if (child !== selectedSlotOption) return child; if (child !== selectedSlotOption) return child;
return { return applyProp(child, 'isFocused', true);
...child, });
componentOptions: { });
...child.componentOptions,
propsData: {
...child.componentOptions.propsData,
isFocused: true,
}
}
};
}));
} }
for (let option of slotOptions) { for (let option of slotOptions) {