@gitlab/ui
Version:
GitLab UI Components
56 lines (50 loc) • 2.06 kB
JavaScript
import Vue from 'vue';
import { mergeData as mergeData$1 } from 'vue-functional-data-merge';
// --- Constants ---
const COMPONENT_UID_KEY = '_uid';
const isGlobalVue3 = Vue.version.startsWith('3');
const REF_FOR_KEY = isGlobalVue3 ? 'ref_for' : 'refInFor';
if (isGlobalVue3) {
const originalVModelDynamicCreated = Vue.vModelDynamic.created;
const originalVModelDynamicBeforeUpdate = Vue.vModelDynamic.beforeUpdate;
let assignSymbol;
// See https://github.com/vuejs/vue-next/pull/4121 for details
Vue.vModelDynamic.created = function (el, binding, vnode) {
originalVModelDynamicCreated.call(this, el, binding, vnode);
if (!el._assign) {
el._assign = () => {};
}
// Added check for Symbol('_assign') to fix in compat 3.3.5+ based on https://github.com/bootstrap-vue/bootstrap-vue/issues/7181
if (!assignSymbol) {
assignSymbol = Object.getOwnPropertySymbols(el).find(s => s.description === '_assign');
}
if (!el[assignSymbol]) {
el[assignSymbol] = function () {};
}
};
Vue.vModelDynamic.beforeUpdate = function (el, binding, vnode) {
originalVModelDynamicBeforeUpdate.call(this, el, binding, vnode);
if (!el._assign) {
el._assign = () => {};
}
// Added check for Symbol('_assign') to fix in 3.3.5+ based on https://github.com/bootstrap-vue/bootstrap-vue/issues/7181
if (!assignSymbol) {
assignSymbol = Object.getOwnPropertySymbols(el).find(s => s.description === '_assign');
}
if (!el[assignSymbol]) {
el[assignSymbol] = function () {};
}
};
}
const isVue3 = instance => Boolean(instance.$);
const extend = Vue.extend.bind(Vue);
function mergeData() {
var _result$attrs, _result$props;
const result = mergeData$1(...arguments);
return {
...result,
...((_result$attrs = result.attrs) !== null && _result$attrs !== void 0 ? _result$attrs : {}),
...((_result$props = result.props) !== null && _result$props !== void 0 ? _result$props : {})
};
}
export { COMPONENT_UID_KEY, REF_FOR_KEY, extend, isGlobalVue3, isVue3, mergeData };