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BAAI,CAAC,MAAL,EAAa;AACX,0DAAuC,KAAK,MAAL,IAAe,YAAtD,GAAsE,IAAtE;AACA;AACD;AAED,mBAAO,YAAP,CACE,KAAK,KAAL,CAAW,OADb,EAEE,OAAO,UAFT;AAKA,iBAAK,WAAL,GAAmB,IAAnB;AACD;AAzCM;AA/DI,CAAf","sourcesContent":["import Bootable from './bootable'\nimport { consoleWarn } from '../util/console'\n\nfunction validateAttachTarget (val) {\n const type = typeof val\n\n if (type === 'boolean' || type === 'string') return true\n\n return val.nodeType === Node.ELEMENT_NODE\n}\n\n/* @vue/component */\nexport default {\n name: 'detachable',\n\n mixins: [Bootable],\n\n props: {\n attach: {\n type: null,\n default: false,\n validator: validateAttachTarget\n },\n contentClass: {\n default: ''\n }\n },\n\n data: () => ({\n hasDetached: false\n }),\n\n watch: {\n attach () {\n this.hasDetached = false\n this.initDetach()\n },\n hasContent: 'initDetach'\n },\n\n beforeMount () {\n this.$nextTick(() => {\n if (this.activatorNode) {\n const activator = Array.isArray(this.activatorNode) ? this.activatorNode : [this.activatorNode]\n activator.forEach(node => {\n node.elm && this.$el.parentNode.insertBefore(node.elm, this.$el)\n })\n }\n })\n },\n\n mounted () {\n !this.lazy && this.initDetach()\n },\n\n deactivated () {\n this.isActive = false\n },\n\n beforeDestroy () {\n // IE11 Fix\n try {\n if (this.$refs.content) {\n this.$refs.content.parentNode.removeChild(this.$refs.content)\n }\n\n if (this.activatorNode) {\n const activator = Array.isArray(this.activatorNode) ? this.activatorNode : [this.activatorNode]\n activator.forEach(node => {\n node.elm && node.elm.parentNode.removeChild(node.elm)\n })\n }\n } catch (e) { console.log(e) }\n },\n\n methods: {\n getScopeIdAttrs () {\n const scopeId = this.$vnode && this.$vnode.context.$options._scopeId\n return scopeId && {\n [scopeId]: ''\n }\n },\n initDetach () {\n if (this._isDestroyed ||\n !this.$refs.content ||\n this.hasDetached ||\n // Leave menu in place if attached\n // and dev has not changed target\n this.attach === '' || // If used as a boolean prop (<v-menu attach>)\n this.attach === true || // If bound to a boolean (<v-menu :attach=\"true\">)\n this.attach === 'attach' // If bound as boolean prop in pug (v-menu(attach))\n ) return\n\n let target\n if (this.attach === false) {\n // Default, detach to app\n target = document.querySelector('[data-app]')\n } else if (typeof this.attach === 'string') {\n // CSS selector\n target = document.querySelector(this.attach)\n } else {\n // DOM Element\n target = this.attach\n }\n\n if (!target) {\n consoleWarn(`Unable to locate target ${this.attach || '[data-app]'}`, this)\n return\n }\n\n target.insertBefore(\n this.$refs.content,\n target.firstChild\n )\n\n this.hasDetached = true\n }\n }\n}\n"],"sourceRoot":""}
|