diff --git a/components/_util/Clone.vue b/components/_util/Clone.vue
index 96ba840df..d9091c0cf 100644
--- a/components/_util/Clone.vue
+++ b/components/_util/Clone.vue
@@ -6,12 +6,13 @@ export default {
childProps: PropTypes.object.def({}),
},
render () {
- const { $attrs, $listeners, childProps } = this
- let children = this.$slots.default[0]
+ const { $attrs, $listeners, childProps, $slots } = this
+ let children = $slots.default[0]
children = cloneElement(children, {
attr: $attrs,
on: $listeners,
props: childProps,
+ addChildren: $slots.addChildren,
})
return children
},
diff --git a/components/_util/vnode.js b/components/_util/vnode.js
index 0687134a5..fc2ba0ddd 100644
--- a/components/_util/vnode.js
+++ b/components/_util/vnode.js
@@ -1,6 +1,11 @@
import cloneDeep from 'lodash.clonedeep'
export function cloneVNode (vnode, deep) {
const componentOptions = vnode.componentOptions
+ // if (componentOptions && componentOptions.listeners) {
+ // componentOptions.listeners = cloneDeep(componentOptions.listeners)
+ // }
+
+ // const data = vnode.data ? cloneDeep(vnode.data) : vnode.data
const cloned = new vnode.constructor(
vnode.tag,
vnode.data,
@@ -54,9 +59,10 @@ export function cloneElement (n, nodeProps, clone) {
node.componentOptions.listeners = node.componentOptions.listeners || {}
node.componentOptions.propsData = { ...node.componentOptions.propsData, ...props }
node.componentOptions.listeners = { ...node.componentOptions.listeners, ...on }
- addChildren && node.componentOptions.children.push(addChildren)
+ node.componentOptions.children = node.componentOptions.children.filter(c => c.key !== '_ANT_PORTAL')
+ addChildren && node.componentOptions.children.push(...addChildren)
} else {
- addChildren && (node.children = [...(node.children || []), addChildren])
+ addChildren && (node.children = [...(node.children || []), ...addChildren])
node.data.on = { ...(node.data.on || {}), ...on }
}
@@ -96,5 +102,5 @@ export function getEvents (child) {
} else if (child.data && child.data.on) {
events = child.data.on
}
- return { ...events }
+ return events
}
diff --git a/components/menu/MenuItem.vue b/components/menu/MenuItem.vue
index 3cfa42d8e..52cee4df9 100644
--- a/components/menu/MenuItem.vue
+++ b/components/menu/MenuItem.vue
@@ -21,14 +21,13 @@ export default {
const itemProps = {
props,
attrs,
- on: { ...$listeners },
+ on: $listeners,
class: getClass(this),
style: getStyle(this),
}
const toolTipProps = {
props: {
placement: 'right',
- trigger: 'click',
overlayClassName: `${props.rootPrefixCls}-inline-collapsed-tooltip`,
},
on: {},
@@ -37,8 +36,7 @@ export default {
{...toolTipProps}
>
- jdjjdj
- {inlineCollapsed && props.level === 1 ? $slots : ''}
+ {inlineCollapsed && props.level === 1 ? $slots.default : ''}
-
{$slots.default}
diff --git a/components/menu/demo/inline-collapsed.vue b/components/menu/demo/inline-collapsed.vue
index 23e1c2608..1ccb41a57 100644
--- a/components/menu/demo/inline-collapsed.vue
+++ b/components/menu/demo/inline-collapsed.vue
@@ -9,10 +9,6 @@
-
@@ -71,6 +67,15 @@ export default {
toggleCollapsed () {
this.collapsed = !this.collapsed
},
+ con1 () {
+ console.log(111)
+ },
+ con2 () {
+ console.log(222)
+ },
+ con3 () {
+ console.log(333)
+ },
},
components: {
Menu,
diff --git a/components/trigger/index.vue b/components/trigger/index.vue
index 4994983a0..bb3cbe58d 100644
--- a/components/trigger/index.vue
+++ b/components/trigger/index.vue
@@ -16,7 +16,6 @@ function returnEmptyString () {
function returnDocument () {
return window.document
}
-
const ALL_HANDLERS = ['click', 'mousedown', 'touchStart', 'mouseenter',
'mouseleave', 'focus', 'blur', 'contextMenu']
@@ -262,6 +261,7 @@ export default {
getRootDomNode () {
return this.$el
+ // return this.$el.children[0] || this.$el
},
handleGetPopupClassFromAlign (align) {
@@ -322,11 +322,11 @@ export default {
},
ref: 'popup',
style: popupStyle,
+ key: '_ANT_PORTAL',
}
return (
{typeof popup === 'function' ? popup(h) : popup}
{popup === undefined ? $slots.popup : null}
@@ -396,7 +396,7 @@ export default {
}
},
- createTwoChains (event, child) {
+ createTwoChains (event) {
let fn = () => {
}
const events = this.$listeners
@@ -463,17 +463,21 @@ export default {
warning(false, 'Trigger $slots.default.length > 1, just support only one default', true)
}
const child = children[0]
- this.childOriginEvents = getEvents(child)
+ const events = getEvents(child)
+ // 黑科技,vue暂未发现保留原事件的方法,使用_ANT_EVENT_HACK来判断事件是否更新
+ if (!events._ANT_EVENT_HACK) {
+ this.childOriginEvents = events
+ }
const newChildProps = {
props: {},
- on: {},
+ on: { _ANT_EVENT_HACK: () => {} },
key: 'trigger',
}
if (this.isContextMenuToShow()) {
newChildProps.on.contextMenu = this.onContextMenu
} else {
- newChildProps.on.contextMenu = this.createTwoChains('contextMenu', child)
+ newChildProps.on.contextMenu = this.createTwoChains('contextMenu')
}
if (this.isClickToHide() || this.isClickToShow()) {
@@ -481,27 +485,27 @@ export default {
newChildProps.on.mousedown = this.onMousedown
// newChildProps.on.touchStart = this.onTouchStart
} else {
- newChildProps.on.click = this.createTwoChains('click', child)
- newChildProps.on.mousedown = this.createTwoChains('mousedown', child)
- // newChildProps.on.TouchStart = this.createTwoChains('onTouchStart', child)
+ newChildProps.on.click = this.createTwoChains('click')
+ newChildProps.on.mousedown = this.createTwoChains('mousedown')
+ // newChildProps.on.TouchStart = this.createTwoChains('onTouchStart')
}
if (this.isMouseEnterToShow()) {
newChildProps.on.mouseenter = this.onMouseenter
} else {
- newChildProps.on.mouseenter = this.createTwoChains('mouseenter', child)
+ newChildProps.on.mouseenter = this.createTwoChains('mouseenter')
}
if (this.isMouseLeaveToHide()) {
newChildProps.on.mouseleave = this.onMouseleave
} else {
- newChildProps.on.mouseleave = this.createTwoChains('mouseleave', child)
+ newChildProps.on.mouseleave = this.createTwoChains('mouseleave')
}
if (this.isFocusToShow() || this.isBlurToHide()) {
newChildProps.on.focus = this.onFocus
newChildProps.on.blur = this.onBlur
} else {
- newChildProps.on.focus = this.createTwoChains('focus', child)
- newChildProps.on.blur = this.createTwoChains('blur', child)
+ newChildProps.on.focus = this.createTwoChains('focus')
+ newChildProps.on.blur = this.createTwoChains('blur')
}
const { sPopupVisible, forceRender } = this
if (sPopupVisible || forceRender || this._component) {
@@ -509,8 +513,8 @@ export default {
} else {
this._component = null
}
- newChildProps.addChildren = this._component
- const trigger = cloneElement(child, newChildProps, true)
+ this._component && (newChildProps.addChildren = [this._component])
+ const trigger = cloneElement(child, newChildProps)
return trigger
},
}