pull/9/head
tangjinzhou 2018-03-01 10:21:06 +08:00
parent 44cae3f86d
commit 222551e232
5 changed files with 10 additions and 10 deletions

View File

@ -51,7 +51,7 @@ export function cloneVNodes (vnodes, deep) {
return res
}
export function cloneElement (n, nodeProps, clone) {
export function cloneElement (n, nodeProps, deep) {
let ele = n
if (Array.isArray(n)) {
ele = filterEmpty(n)[0]
@ -59,7 +59,7 @@ export function cloneElement (n, nodeProps, clone) {
if (!ele) {
return null
}
const node = clone ? cloneVNode(ele, true) : ele
const node = cloneVNode(ele, deep)
const { props = {}, key, on = {}, children } = nodeProps
const data = node.data || {}
const { style = data.style,

View File

@ -1,6 +1,6 @@
<script>
import PropTypes from '../_util/vue-types'
import { cloneElement, cloneVNode } from '../_util/vnode'
import { cloneElement } from '../_util/vnode'
function chaining (...fns) {
return function (...args) { // eslint-disable-line
// eslint-disable-line
@ -31,7 +31,7 @@ export default {
render () {
const { $slots = {}, $listeners = {}, $props = {}, $attrs = {}} = this
const value = $props.value === undefined ? '' : $props.value
const children = cloneVNode($slots.default[0])
const children = $slots.default[0]
const { componentOptions = {}} = $slots.default[0]
const { listeners = {}} = componentOptions
const newEvent = { ...listeners }

View File

@ -21,7 +21,7 @@ Customize Input Component
placeholder="input here"
class="custom"
style="height: 50px"
@keypress="handleKeyPress"
@keydown="handleKeyPress"
/>
</a-auto-complete>
</template>

View File

@ -4,7 +4,7 @@ import Trigger from '../../trigger'
import placements from './placements'
import { hasProp, getEvents } from '../../_util/props-util'
import BaseMixin from '../../_util/BaseMixin'
import { cloneElement, cloneVNode } from '../../_util/vnode'
import { cloneElement } from '../../_util/vnode'
export default {
mixins: [BaseMixin],
@ -70,7 +70,7 @@ export default {
getMenuElement () {
const { onClick, prefixCls, $slots } = this
this.childOriginEvents = getEvents($slots.overlay[0])
return cloneElement(cloneVNode($slots.overlay[0]), {
return cloneElement($slots.overlay[0], {
props: {
prefixCls: `${prefixCls}-menu`,
},

View File

@ -9,7 +9,7 @@ import warning from '../_util/warning'
import Popup from './Popup'
import { getAlignFromPlacement, getPopupClassNameFromAlign, noop } from './utils'
import BaseMixin from '../_util/BaseMixin'
import { cloneElement, cloneVNode } from '../_util/vnode'
import { cloneElement } from '../_util/vnode'
function returnEmptyString () {
return ''
@ -498,8 +498,8 @@ export default {
if (children.length > 1) {
warning(false, 'Trigger $slots.default.length > 1, just support only one default', true)
}
const child = cloneVNode(children[0])
this.childOriginEvents = getEvents(children[0])
const child = children[0]
this.childOriginEvents = getEvents(child)
const newChildProps = {
props: {},
on: {},