github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/themes/wind/static/libs/vue-1.0.24/src/directives/public/show.js (about) 1 import { getAttr, inDoc } from '../../util/index' 2 import { applyTransition } from '../../transition/index' 3 4 export default { 5 6 bind () { 7 // check else block 8 var next = this.el.nextElementSibling 9 if (next && getAttr(next, 'v-else') !== null) { 10 this.elseEl = next 11 } 12 }, 13 14 update (value) { 15 this.apply(this.el, value) 16 if (this.elseEl) { 17 this.apply(this.elseEl, !value) 18 } 19 }, 20 21 apply (el, value) { 22 if (inDoc(el)) { 23 applyTransition(el, value ? 1 : -1, toggle, this.vm) 24 } else { 25 toggle() 26 } 27 function toggle () { 28 el.style.display = value ? '' : 'none' 29 } 30 } 31 }