All files / vue-feature-flipping/src directive.js

100% Statements 4/4
100% Branches 2/2
100% Functions 1/1
100% Lines 4/4

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                      10x 10x 5x 5x      
import { isEnabled } from './service'
import { parseParameter } from './utils'
 
/**
 * @param {(string|{key: string, default: boolean})} binding.value
 * @example
 * <div v-feature-flipping="'XXXXX'">...</div>
 * <div v-feature-flipping="{ key: 'XXXXX' }">...</div>
 * <div v-feature-flipping="{ key: 'XXXXX', default: true }">...</div>
 */
export async function featureFlippingDirective (el, binding, vnode, oldVnode) {
  let [key, defaut] = parseParameter(binding.value)
  if (!isEnabled(key, defaut)) {
    await vnode.context.$nextTick()
    vnode.elm.remove()
  }
}