ant-design-vue/components/auto-complete/InputElement.jsx

60 lines
1.8 KiB
Vue
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { cloneElement } from '../_util/vnode';
2020-07-01 16:24:44 +00:00
import { flattenChildren } from '../_util/props-util';
// function chaining(...fns) {
// return function(...args) {
// // eslint-disable-line
// // eslint-disable-line
// for (let i = 0; i < fns.length; i++) {
// if (fns[i] && typeof fns[i] === 'function') {
// fns[i].apply(this, args);
// }
// }
// };
// }
// export default {
// name: 'InputElement',
// inheritAttrs: false,
// props: {
// value: PropTypes.any,
// disabled: PropTypes.bool,
// placeholder: PropTypes.string,
// },
// render() {
// const { $slots = {}, $attrs = {}, placeholder } = this;
// const listeners = getListeners(this);
// const props = getOptionProps(this);
// const value = props.value === undefined ? '' : props.value;
// const children = getSlot(this)[0];
// const { componentOptions = {} } = $slots.default[0];
// const { listeners: events = {} } = componentOptions;
// const newEvent = { ...events };
2018-02-28 15:30:40 +00:00
2020-07-01 16:24:44 +00:00
// for (const [eventName, event] of Object.entries(listeners)) {
// newEvent[eventName] = chaining(event, events[eventName]);
// }
// const attrs = { ...$attrs, value };
// // https://github.com/vueComponent/ant-design-vue/issues/1761
// delete props.placeholder;
// if (placeholder) {
// props.placeholder = placeholder;
// attrs.placeholder = placeholder;
// }
// return cloneElement(children, {
// domProps: {
// value,
// },
// props,
// on: newEvent,
// attrs,
// ref: 'ele',
// });
// },
// };
const InputElement = (_, { attrs, slots }) => {
const children = flattenChildren(slots.default?.())[0];
return cloneElement(children, { ...attrs });
2019-01-12 03:33:27 +00:00
};
2020-07-01 16:24:44 +00:00
InputElement.inheritAttrs = false;
export default InputElement;