diff --git a/components/_util/props-util.js b/components/_util/props-util.js index 9bb66df42..6dba0f19f 100644 --- a/components/_util/props-util.js +++ b/components/_util/props-util.js @@ -95,19 +95,22 @@ const getOptionProps = (instance) => { return filterProps($props, $options.propsData) } -const getComponentFromProp = (instance, prop, options) => { +const getComponentFromProp = (instance, prop, options = instance, execute = true) => { if (instance.$createElement) { const h = instance.$createElement const temp = instance[prop] if (temp !== undefined) { - return typeof temp === 'function' ? temp(h, options) : temp + return typeof temp === 'function' && execute ? temp(h, options) : temp } - return instance.$slots[prop] || (instance.$scopedSlots[prop] && instance.$scopedSlots[prop](options)) || undefined + return instance.$slots[prop] || + (instance.$scopedSlots[prop] && execute && instance.$scopedSlots[prop](options)) || + (instance.$scopedSlots[prop] && instance.$scopedSlots[prop]) || + undefined } else { const h = instance.context.$createElement const temp = getPropsData(instance)[prop] if (temp !== undefined) { - return typeof temp === 'function' ? temp(h, options) : temp + return typeof temp === 'function' && execute ? temp(h, options) : temp } const slotsProp = [] const componentOptions = instance.componentOptions || {}; diff --git a/components/cascader/index.jsx b/components/cascader/index.jsx index 2cc36d73b..9c7620c40 100644 --- a/components/cascader/index.jsx +++ b/components/cascader/index.jsx @@ -310,7 +310,8 @@ const Cascader = { const { $slots, sPopupVisible, inputValue, $listeners } = this const { sValue: value, inputFocused } = this.$data const props = getOptionProps(this) - const suffixIcon = getComponentFromProp(this, 'suffixIcon') + let suffixIcon = getComponentFromProp(this, 'suffixIcon') + suffixIcon = Array.isArray(suffixIcon) ? suffixIcon[0] : suffixIcon const { prefixCls, inputPrefixCls, placeholder, size, disabled, allowClear, showSearch = false, ...otherProps } = props @@ -408,9 +409,9 @@ const Cascader = { } const children = filterEmpty($slots.default) const inputIcon = suffixIcon && ( - isValidElement(suffixIcon[0]) + isValidElement(suffixIcon) ? cloneElement( - suffixIcon[0], + suffixIcon, { class: { [`${prefixCls}-picker-arrow`]: true, diff --git a/components/form/__tests__/__snapshots__/demo.test.js.snap b/components/form/__tests__/__snapshots__/demo.test.js.snap index a3588a5c1..99969e364 100644 --- a/components/form/__tests__/__snapshots__/demo.test.js.snap +++ b/components/form/__tests__/__snapshots__/demo.test.js.snap @@ -4,7 +4,7 @@ exports[`renders ./components/form/demo/advanced-search.vue correctly 1`] = `