MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / evaluate

Function evaluate

src/_hyperscript.js:97–121  ·  view source on GitHub ↗
(src, ctx, args)

Source from the content-addressed store, hash-verified

95// ===== Public API =====
96
97function evaluate(src, ctx, args) {
98 let body;
99 if ('document' in globalScope) {
100 body = globalScope.document.body;
101 } else {
102 body = new HyperscriptModule(args && args.module);
103 }
104
105 ctx = Object.assign(runtime.makeContext(body, null, body, null), ctx || {});
106 let element = kernel.parse(tokenizer, src);
107
108 if (element && element.errors && element.errors.length > 0) {
109 throw new Error(element.errors[0].message + "\n\n" + Parser.formatErrors(element.errors));
110 }
111
112 if (element.execute) {
113 element.execute(ctx);
114 return ctx.meta.returnValue !== undefined ? ctx.meta.returnValue : ctx.result;
115 } else if (element.apply) {
116 element.apply(body, body, args, runtime);
117 return runtime.getHyperscriptFeatures(body);
118 } else {
119 return element.evaluate(ctx);
120 }
121}
122
123const _hyperscript = Object.assign(
124 evaluate,

Callers

nothing calls this directly

Calls 7

makeContextMethod · 0.45
parseMethod · 0.45
formatErrorsMethod · 0.45
executeMethod · 0.45
applyMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected