$create: assign style property as a string/object

This commit is contained in:
tophf 2020-11-23 23:22:37 +03:00
parent eb99101f35
commit b59737a012

View File

@ -278,6 +278,12 @@ function $create(selector = 'div', properties, children) {
delete opt.attributes; delete opt.attributes;
} }
if (opt.style) {
if (typeof opt.style === 'string') element.style.cssText = opt.style;
if (typeof opt.style === 'object') Object.assign(element.style, opt.style);
delete opt.style;
}
if (ns) { if (ns) {
for (const attr in opt) { for (const attr in opt) {
const i = attr.indexOf(':') + 1; const i = attr.indexOf(':') + 1;