UNPKG

jiku-ui

Version:

A Component Library for Vue.js.

33 lines (28 loc) 596 B
const inheritKey = [ 'ref', 'style', 'class', 'attrs', 'nativeOn', 'directives', 'staticClass', 'staticStyle' ]; const mapInheritKey = { nativeOn: 'on' }; // inherit partial context, map nativeOn to on export function inherit(context, inheritListeners) { const result = inheritKey.reduce( (obj, key) => { if (context.data[key]) { obj[mapInheritKey[key] || key] = context.data[key]; } return obj; }, {} ); if (inheritListeners) { result.on = result.on || {}; Object.assign(result.on, context.data.on); } return result; }