Blame view

src/directive/theme.js 995 Bytes
任超 committed
1
export const theme = {
yuanbo committed
2 3 4 5 6 7 8
  /**
   * @description: bind
   * @param {*} el
   * @param {*} binding
   * @param {*} vnode
   * @author: renchao
   */
任超 committed
9 10 11
  bind: function (el, binding, vnode) {
    setEleStyleColorAttribute(el, binding);
  },
yuanbo committed
12 13 14 15 16 17 18
  /**
   * @description: update
   * @param {*} el
   * @param {*} binding
   * @param {*} vnode
   * @author: renchao
   */
任超 committed
19 20 21
  update: function (el, binding, vnode) {
    setEleStyleColorAttribute(el, binding);
  },
yuanbo committed
22 23 24 25 26 27 28
  /**
   * @description: componentUpdated
   * @param {*} el
   * @param {*} binding
   * @param {*} vnode
   * @author: renchao
   */
任超 committed
29 30 31 32 33 34 35 36 37 38 39
  componentUpdated: function (el, binding, vnode) {
    setEleStyleColorAttribute(el, binding);
  }
}

function setEleStyleColorAttribute (el, binding) {
  const { name, value, arg, expression, modifiers } = binding;
  const { background, font, border } = modifiers;
  if (background) el.style['background-color'] = value;
  if (font) el.style.color = value;
  if (border) el.style['border-color'] = value;
yuanbo committed
40
}