diff --git a/dreamland.d.ts b/dreamland.d.ts index 03f637e..0f0f883 100644 --- a/dreamland.d.ts +++ b/dreamland.d.ts @@ -45,8 +45,8 @@ declare function $store( options: { ident: string backing: - | 'localstorage' - | { read: () => string; write: (value: string) => void } + | 'localstorage' + | { read: () => string; write: (value: string) => void } autosave: 'auto' | 'manual' | 'beforeunload' } ): Stateful @@ -77,7 +77,7 @@ interface DLElement extends HTMLElement { } type ComponentElement any> = ReturnType -type ComponentType any> = ReturnType["$"] +type ComponentType any> = ReturnType['$'] type OuterComponentTypes = { root: Element @@ -98,6 +98,6 @@ type Component = ( Private extends { children: any } ? Private['children'] : never > } & { - [K in keyof Props as `bind:${Extract}`]?: DLPointer - } + [K in keyof Props as `bind:${Extract}`]?: DLPointer + } ) => DLElement diff --git a/src/core.js b/src/core.js index c3ef233..9a375cf 100644 --- a/src/core.js +++ b/src/core.js @@ -575,6 +575,7 @@ function JSXAddChild(child, cb) { // Where properties are assigned to elements, and where the *non-reactive* syntax sugar goes function JSXAddAttributes(elm, name, prop) { + if (!prop && elm.hasAttribute(name)) elm.removeAttribute(name) if (!prop) return if (name.startsWith('on:')) { diff --git a/src/css.js b/src/css.js index 9d15605..7d1a1a6 100644 --- a/src/css.js +++ b/src/css.js @@ -96,7 +96,7 @@ export function genCss(uid, str, scoped) { let extstr = '' for (const rule of styleElement.sheet.cssRules) { - if (!rule.selectorText) { + if (!rule.selectorText && !rule.media) { extstr += rule.cssText } else if (rule.selectorText?.startsWith(':')) { rule.selectorText = `.${uid}${rule.selectorText}` @@ -109,7 +109,18 @@ export function genCss(uid, str, scoped) { styleElement.textContent = `.${uid} {${selfstr}} @scope (.${uid}) to (:not(.${uid}).${cssBoundary} *) { ${newstr} } ${extstr}` } else { for (const rule of styleElement.sheet.cssRules) { - rule.selectorText = `.${uid} ${rule.selectorText}` + if (rule.selectorText) + rule.selectorText = rule.selectorText + .split(',') + .map((x) => { + x = x.trim() + if (x[0] === ':') { + return `.${uid}${x}` + } else { + return `.${uid} ${x}` + } + }) + .join(', ') newstr += rule.cssText }