1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-07-01 12:22:15 +02:00
This commit is contained in:
2023-11-08 19:09:39 +01:00
parent 5c038f0427
commit 4d3a513713
10 changed files with 39 additions and 31 deletions

View File

@ -4,7 +4,8 @@ import { signals } from "./signals-common.js";
const scopes= [ {
scope: document.body,
host: c=> c ? c(document.body) : document.body,
prevent: true
prevent: true,
inherit_host: false,
} ];
export const scope= {
get current(){ return scopes[scopes.length-1]; },
@ -24,7 +25,7 @@ export const scope= {
};
let namespace;
export function createElement(tag, attributes, ...modifiers){
/* jshint maxcomplexity: 15 */
/* jshint maxcomplexity: 16 */
const s= signals(this);
let scoped= 0;
let el, el_host;
@ -34,7 +35,9 @@ export function createElement(tag, attributes, ...modifiers){
switch(true){
case typeof tag==="function": {
scoped= 1;
scope.push({ scope: tag, host: c=> c ? (scoped===1 ? modifiers.unshift(c) : c(el_host), undefined) : el_host });
const { inherit_host, host: hostParent }= scope.current;
const host= inherit_host ? hostParent : c=> c ? (scoped===1 ? modifiers.unshift(c) : c(el_host), undefined) : el_host;
scope.push({ scope: tag, host, inherit_host });
el= tag(attributes || undefined);
const is_fragment= el instanceof DocumentFragment;
const el_mark= createElement.mark({