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

View File

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

View File

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

View File

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

View File

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