vue-validator
Version:
Validator component for Vue.js
26 lines (23 loc) • 738 B
JavaScript
/* @flow */
import props, { DEFAULT_CLASSES } from './validity/props'
export default function (Vue: GlobalAPI): Object {
const { extend } = Vue.util
return {
functional: true,
props,
render (
h: Function,
{ props, data, children }
): Array<VNode> {
return children.map((child: VNode): VNode => {
if (!child.tag) { return child }
const newData: Object = extend({}, data)
newData.props = extend({}, props)
// TODO: should be refactored
newData.props.classes = extend(extend(extend({}, DEFAULT_CLASSES), Vue.config.validator.classes), newData.props.classes)
newData.props.child = child
return h('validity-control', newData)
})
}
}
}