MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / _assignTo

Function _assignTo

src/parsetree/features/bind.js:277–294  ·  view source on GitHub ↗

* Assign a value to a parsed expression target. Delegates to the * expression's own set() method (same contract as the set command), * with bind-specific coercion for classes and boolean attributes.

(runtime, target, ctx, value)

Source from the content-addressed store, hash-verified

275 * with bind-specific coercion for classes and boolean attributes.
276 */
277function _assignTo(runtime, target, ctx, value) {
278 if (target.type === "classRef") {
279 var elt = ctx.you || ctx.me;
280 if (elt) value ? elt.classList.add(target.className) : elt.classList.remove(target.className);
281 } else if (target.type === "attributeRef" && typeof value === "boolean") {
282 var elt = ctx.you || ctx.me;
283 if (elt) _setAttr(elt, target.name, value);
284 } else {
285 var lhs = {};
286 if (target.lhs) {
287 for (var key in target.lhs) {
288 var expr = target.lhs[key];
289 lhs[key] = expr && expr.evaluate ? expr.evaluate(ctx) : expr;
290 }
291 }
292 target.set(ctx, lhs, value);
293 }
294}

Callers 1

_createExpressionSideFunction · 0.70

Calls 3

_setAttrFunction · 0.70
evaluateMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected