All files / src/instance expose.ts

50% Statements 6/12
37.5% Branches 3/8
33.33% Functions 1/3
50% Lines 6/12

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  1x 1x   2x 2x                          
export function initExposed(vm) {
  const expose = vm.$options.expose || {}
  if (Array.isArray(expose)) {
    if (expose.length) {
      const exposed = {}
    I  expose.forEach((key) => {
        Object.defineProperty(exposed, key, {
          get: (...args) => {
            return typeof this.$component[key] === 'function'
              ? this.$component[key].call(this.$component, ...args)
              : this.$component[key]
          },
        })
      })
      return exposed
    }
  }
  return {}
}