26 lines
612 B
26 lines
612 B
import { isNull, isObject, each, trim, camelize } from "../../2.base"; |
|
|
|
export const registCssFun = Element => { |
|
Element.registerFunction("css", function (key, value) { |
|
if (isObject(key)) { |
|
each(key, (k, v) => { |
|
this.css(k, v); |
|
}); |
|
|
|
return this; |
|
} |
|
key = trim(camelize(key)); |
|
|
|
return css(this, key, value); |
|
}); |
|
}; |
|
|
|
const css = (elem, key, value) => { |
|
key = trim(camelize(key)); |
|
if (isNull(value)) { |
|
return elem.styles[key]; |
|
} |
|
elem.styles[key] = value; |
|
|
|
return elem; |
|
};
|
|
|