All files / src/instance expose.ts

33.33% Statements 6/18
25% Branches 3/12
20% Functions 1/5
33.33% Lines 6/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25  1x 1x   20x 20x                               1x      
export function initExposed(vm) {
  const expose = vm.$options.expose || {}
  if (Array.isArray(expose)) {
    if (expose.length) {
      const exposed = vm._exposed || (vm._exposed = {})
    I  expose.forEach((key) => {
        Object.defineProperty(exposed, key, {
          get: () => vm[key],
          set: (val) => (vm[key] = val)
        })
      })
      return exposed
    } else if (!vm._exposed) {
      vm._exposed = {}
    }
  }
}

export function getPublicInstance(vm) {
  if (vm._exposed) {
    return vm._exposed
  }
  return vm
}