From 4df4424570b6c67fd90de72f98f17232d596f130 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Wed, 13 Feb 2019 22:11:27 +0800 Subject: [PATCH] perf: update to vue 2.6.x --- components/_util/props-util.js | 10 +++++++++- components/vc-align/Align.jsx | 5 +++-- package.json | 12 ++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/components/_util/props-util.js b/components/_util/props-util.js index 8e94a5474..e1141e6e7 100644 --- a/components/_util/props-util.js +++ b/components/_util/props-util.js @@ -60,6 +60,13 @@ const getSlots = ele => { }); return slots; }; +const getSlot = (self, name = 'default', options = {}) => { + return ( + (self.$scopedSlots && self.$scopedSlots[name] && self.$scopedSlots[name](options)) || + self.$slots[name] || + [] + ); +}; const getAllChildren = ele => { let componentOptions = ele.componentOptions || {}; if (ele.$vnode) { @@ -105,9 +112,9 @@ const getComponentFromProp = (instance, prop, options = instance, execute = true return typeof temp === 'function' && execute ? temp(h, options) : temp; } return ( - instance.$slots[prop] || (instance.$scopedSlots[prop] && execute && instance.$scopedSlots[prop](options)) || instance.$scopedSlots[prop] || + instance.$slots[prop] || undefined ); } else { @@ -289,6 +296,7 @@ export { isValidElement, camelize, getSlots, + getSlot, getAllProps, getAllChildren, }; diff --git a/components/vc-align/Align.jsx b/components/vc-align/Align.jsx index 4fecea4f1..a7922ac68 100644 --- a/components/vc-align/Align.jsx +++ b/components/vc-align/Align.jsx @@ -4,6 +4,7 @@ import addEventListener from '../_util/Dom/addEventListener'; import { isWindow, buffer, isSamePoint } from './util'; import { cloneElement } from '../_util/vnode.js'; import clonedeep from 'lodash/cloneDeep'; +import { getSlot } from '../_util/props-util'; function getElement(func) { if (typeof func !== 'function' || !func) return null; @@ -133,8 +134,8 @@ export default { render() { const { childrenProps } = this.$props; - const child = this.$slots.default[0]; - if (childrenProps) { + const child = getSlot(this)[0]; + if (child && childrenProps) { return cloneElement(child, { props: childrenProps }); } return child; diff --git a/package.json b/package.json index b0b803f96..ca0dc8a67 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,8 @@ "prettier" ], "peerDependencies": { - "vue": ">=2.5.0", - "vue-template-compiler": ">=2.5.0" + "vue": ">=2.6.6", + "vue-template-compiler": ">=2.6.6" }, "devDependencies": { "@commitlint/cli": "^6.2.0", @@ -153,17 +153,17 @@ "through2": "^2.0.3", "uglifyjs-webpack-plugin": "^2.1.1", "url-loader": "^1.1.2", - "vue": "^2.5.16", + "vue": "^2.6.6", "vue-antd-md-loader": "^1.1.0", "vue-clipboard2": "0.0.8", "vue-eslint-parser": "^5.0.0", "vue-i18n": "^8.3.2", "vue-infinite-scroll": "^2.0.2", "vue-jest": "^2.5.0", - "vue-loader": "^15.5.1", + "vue-loader": "^15.6.2", "vue-router": "^3.0.1", - "vue-server-renderer": "^2.5.16", - "vue-template-compiler": "^2.5.16", + "vue-server-renderer": "^2.6.6", + "vue-template-compiler": "^2.6.6", "vue-virtual-scroller": "^0.12.0", "vuex": "^3.1.0", "webpack": "^4.28.4",