MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / h

Function h

example/tests/gm_download_test.js:78–87  ·  view source on GitHub ↗
(tag, props = {}, ...children)

Source from the content-addressed store, hash-verified

76
77 // ---------- Tiny DOM helper ----------
78 function h(tag, props = {}, ...children) {
79 const el = document.createElement(tag);
80 Object.entries(props).forEach(([k, v]) => {
81 if (k === "style" && typeof v === "object") Object.assign(el.style, v);
82 else if (k.startsWith("on") && typeof v === "function") el.addEventListener(k.slice(2), v);
83 else el[k] = v;
84 });
85 for (const c of children) el.append(c && c.nodeType ? c : document.createTextNode(String(c)));
86 return el;
87 }
88
89 function escapeHtml(s) {
90 return String(s).replace(

Callers 2

logLineFunction · 0.70

Calls 5

forEachMethod · 0.80
entriesMethod · 0.80
addEventListenerMethod · 0.80
appendMethod · 0.80
sliceMethod · 0.45

Tested by

no test coverage detected