2023-09-13 21:37:00 +02:00
|
|
|
//TODO: https://www.npmjs.com/package/html-element
|
2023-09-13 21:06:13 +02:00
|
|
|
import { prop_process } from './src/dom-common.js';
|
2023-09-13 13:02:17 +02:00
|
|
|
const { setDelete }= prop_process;
|
|
|
|
/** @param {HTMLElement} obj */
|
|
|
|
prop_process.setDelete= function(obj, prop, value){
|
|
|
|
if("checked"!==prop) return setDelete(obj, prop, value);
|
|
|
|
if(value) return obj.setAttribute("checked", "");
|
|
|
|
obj.removeAttribute("checked");
|
2023-09-13 13:20:00 +02:00
|
|
|
};
|
2023-09-06 14:54:02 +02:00
|
|
|
const keys= [ "HTMLElement", "SVGElement", "DocumentFragment", "MutationObserver", "document" ];
|
|
|
|
let dom_last;
|
2023-09-13 21:37:00 +02:00
|
|
|
|
|
|
|
export let namespace;
|
|
|
|
export let createElement;
|
2023-09-06 14:54:02 +02:00
|
|
|
export let el;
|
|
|
|
export let assign;
|
2023-09-13 21:37:00 +02:00
|
|
|
export let classListDeclarative;
|
|
|
|
export let empty;
|
2023-09-06 14:54:02 +02:00
|
|
|
export let on;
|
2023-09-13 21:37:00 +02:00
|
|
|
export let dispatchEvent;
|
|
|
|
|
2023-09-06 14:54:02 +02:00
|
|
|
export async function register(dom, keys_aditional= []){
|
|
|
|
if(dom_last===dom)
|
2023-09-13 21:06:13 +02:00
|
|
|
return import("./index.js");
|
2023-09-06 14:54:02 +02:00
|
|
|
|
|
|
|
keys.push(...keys_aditional);
|
|
|
|
const w= dom.window;
|
|
|
|
keys.forEach(key=> globalThis[key]= w[key]);
|
|
|
|
globalThis.window= w;
|
|
|
|
w.console= globalThis.console;
|
|
|
|
|
2023-09-13 21:06:13 +02:00
|
|
|
const m= await import("./index.js");
|
2023-09-13 21:37:00 +02:00
|
|
|
namespace= m.namespace;
|
|
|
|
createElement= m.createElement;
|
2023-09-06 14:54:02 +02:00
|
|
|
el= m.el;
|
|
|
|
assign= m.assign;
|
2023-09-13 21:37:00 +02:00
|
|
|
classListDeclarative= m.classListDeclarative;
|
|
|
|
empty= m.empty;
|
2023-09-06 14:54:02 +02:00
|
|
|
on= m.on;
|
2023-09-13 21:37:00 +02:00
|
|
|
dispatchEvent= m.dispatchEvent;
|
2023-09-06 14:54:02 +02:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
export function unregister(){
|
|
|
|
if(!dom_last)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
keys.forEach(key=> Reflect.deleteProperty(globalThis, key));
|
|
|
|
Reflect.deleteProperty(globalThis, "window");
|
|
|
|
dom_last= undefined;
|
|
|
|
return true;
|
2023-09-05 11:01:29 +02:00
|
|
|
}
|