Blame view

src/components/select/functional-options.vue 1.05 KB
c9b86944   Sergio Crisostomo   Refactor Select!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  
  <script>
      const returnArrayFn = () => [];
  
      export default {
          props: {
              options: {
                  type: Array,
                  default: returnArrayFn
              },
              slotOptions: {
                  type: Array,
                  default: returnArrayFn
              },
              slotUpdateHook: {
                  type: Function,
                  default: () => {}
              },
          },
          functional: true,
b3279b71   oyv1cent   fix select
21
22
23
24
25
26
27
28
29
30
31
          render(h, {props, parent}) {
              // In order to response data changes,i do this hack. #4372
              if(props.slotOptions.length > 0) {
                  for(let i in props.slotOptions) {
                      if(props.slotOptions[i].key !== parent.$slots.default[i].key) {
                          props.slotUpdateHook();
                          break;
                      }
                  }
              }
              if(props.slotOptions && parent.$slots.default && props.slotOptions.length !== parent.$slots.default.length) props.slotUpdateHook();
c9b86944   Sergio Crisostomo   Refactor Select!
32
33
34
35
              return props.options;
          }
      };
  </script>