MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / dom

Function dom

host/dom/src/index.js:13–39  ·  view source on GitHub ↗
(ctx)

Source from the content-addressed store, hash-verified

11import platform from './main/platform.js';
12
13export const dom = (ctx) => {
14 const state = makeState();
15 let errorMsg = null;
16 // Surfaces async errors (listener throws, observer callbacks, swallowed promise rejections) to Python. Falls back to console.error if no consumer bound via bind_global_error.
17 const emitError = (where, e) => {
18 if (errorMsg) ctx.pushEvent(JSON.stringify({
19 msg: errorMsg,
20 where,
21 error: (e && e.message) ? e.message : String(e),
22 stack: (e && e.stack) ? e.stack : undefined,
23 }));
24 else console.error(`[dom:${where}]`, e);
25 };
26 const ctxPlus = { ...ctx, emitError };
27 return Object.assign(
28 {},
29 tree(state),
30 style(state),
31 events(state, ctxPlus),
32 forms(state, ctxPlus),
33 observers(state, ctxPlus),
34 animations(state, ctxPlus),
35 media(state, ctxPlus),
36 platform(state, ctxPlus),
37 { bind_global_error: (msg) => { errorMsg = msg; } },
38 );
39};
40
41export default dom;

Callers

nothing calls this directly

Calls 2

makeStateFunction · 0.90
assignMethod · 0.80

Tested by

no test coverage detected