From 72102ede33bd2b5f67b9636c888d2c4394e273e1 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Thu, 1 Mar 2018 19:09:45 +0800 Subject: [PATCH] fix --- components/_util/props-util.js | 16 +++++++++++++++- components/vc-menu/SubMenu.vue | 9 +++++---- contributors.md | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/components/_util/props-util.js b/components/_util/props-util.js index 6fc4aea48..81a145734 100644 --- a/components/_util/props-util.js +++ b/components/_util/props-util.js @@ -1,3 +1,17 @@ + +const parseStyleText = (cssText = '') => { + const res = {} + const listDelimiter = /;(?![^(]*\))/g + const propertyDelimiter = /:(.+)/ + cssText.split(listDelimiter).forEach(function (item) { + if (item) { + const tmp = item.split(propertyDelimiter) + tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim()) + } + }) + return res +} + const hasProp = (instance, prop) => { const $options = instance.$options || {} const propsData = $options.propsData || {} @@ -106,7 +120,7 @@ export function getStyle (ele) { } else if (ele.$vnode && ele.$vnode.data) { data = ele.$vnode.data } - return data.style || data.staticStyle + return data.style || parseStyleText(data.staticStyle || '') } export function getComponentName (opts) { diff --git a/components/vc-menu/SubMenu.vue b/components/vc-menu/SubMenu.vue index f42d8ce25..2374b2abc 100644 --- a/components/vc-menu/SubMenu.vue +++ b/components/vc-menu/SubMenu.vue @@ -7,6 +7,7 @@ import placements from './placements' import { loopMenuItemRecusively, noop } from './util' import BaseMixin from '../_util/BaseMixin' import { getComponentFromProp } from '../_util/props-util' +import { requestAnimationTimeout, cancelAnimationTimeout } from '../_util/requestAnimationTimeout' let guid = 0 @@ -73,10 +74,10 @@ export default { // this.clearSubMenuTimers() // } if (this.minWidthTimeout) { - clearTimeout(this.minWidthTimeout) + cancelAnimationTimeout(this.minWidthTimeout) } if (this.mouseenterTimeout) { - clearTimeout(this.mouseenterTimeout) + cancelAnimationTimeout(this.mouseenterTimeout) } }, methods: { @@ -86,7 +87,7 @@ export default { return } const self = this - this.minWidthTimeout = setTimeout(() => { + this.minWidthTimeout = requestAnimationTimeout(() => { if (!self.$refs.subMenuTitle || !self.$refs.menuInstance) { return } @@ -282,7 +283,7 @@ export default { } if (type === 'mouseenter') { // make sure mouseenter happen after other menu item's mouseleave - this.mouseenterTimeout = setTimeout(() => { + this.mouseenterTimeout = requestAnimationTimeout(() => { openChange() }, 0) } else { diff --git a/contributors.md b/contributors.md index 767cf632b..1c22363aa 100644 --- a/contributors.md +++ b/contributors.md @@ -18,7 +18,7 @@ message | done Select | done Input | done InputNumber -AutoComplete +AutoComplete | done Modal Alert Calendar