From b59737a012cefbd23f25926ef01f6ff58d164a68 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 23 Nov 2020 23:22:37 +0300 Subject: [PATCH] $create: assign style property as a string/object --- js/dom.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/dom.js b/js/dom.js index 339a793d..3c961b1f 100644 --- a/js/dom.js +++ b/js/dom.js @@ -278,6 +278,12 @@ function $create(selector = 'div', properties, children) { 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) { for (const attr in opt) { const i = attr.indexOf(':') + 1;