(src, ctx, args)
| 95 | // ===== Public API ===== |
| 96 | |
| 97 | function 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 | |
| 123 | const _hyperscript = Object.assign( |
| 124 | evaluate, |
nothing calls this directly
no test coverage detected