Commit aa21cdf9c3ef6c2bfe529796687049bfbef5f1a9

Authored by Sergio Crisostomo
1 parent 523e2c81

Process also shallow children and not only nested

Showing 1 changed file with 20 additions and 13 deletions   Show diff stats
src/components/select/select.vue
... ... @@ -107,6 +107,19 @@
107 107 return options.concat(findOptionsInVNode(slotEntry));
108 108 }, []);
109 109  
  110 + const applyProp = (node, propName, value) => {
  111 + return {
  112 + ...node,
  113 + componentOptions: {
  114 + ...node.componentOptions,
  115 + propsData: {
  116 + ...node.componentOptions.propsData,
  117 + [propName]: value,
  118 + }
  119 + }
  120 + };
  121 + };
  122 +
110 123 export default {
111 124 name: 'iSelect',
112 125 mixins: [ Emitter, Locale ],
... ... @@ -304,19 +317,13 @@
304 317 const autoCompleteOptions = extractOptions(slotOptions);
305 318 const selectedSlotOption = autoCompleteOptions[currentIndex];
306 319  
307   - return slotOptions.map(node => copyChildren(node, (child) => {
308   - if (child !== selectedSlotOption) return child;
309   - return {
310   - ...child,
311   - componentOptions: {
312   - ...child.componentOptions,
313   - propsData: {
314   - ...child.componentOptions.propsData,
315   - isFocused: true,
316   - }
317   - }
318   - };
319   - }));
  320 + return slotOptions.map(node => {
  321 + if (node === selectedSlotOption) return applyProp(node, 'isFocused', true);
  322 + return copyChildren(node, (child) => {
  323 + if (child !== selectedSlotOption) return child;
  324 + return applyProp(child, 'isFocused', true);
  325 + });
  326 + });
320 327 }
321 328  
322 329 for (let option of slotOptions) {
... ...