* 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)
| 275 | * with bind-specific coercion for classes and boolean attributes. |
| 276 | */ |
| 277 | function _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 | } |
no test coverage detected