Blame view

src/directive/theme.js 611 Bytes
任超 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
export const theme = {
  bind: function (el, binding, vnode) {
    setEleStyleColorAttribute(el, binding);
  },
  update: function (el, binding, vnode) {
    setEleStyleColorAttribute(el, binding);
  },
  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;
}