(context, { to, classRefs, css, value })
| 7665 | } |
| 7666 | } |
| 7667 | resolve(context, { to, classRefs, css, value }) { |
| 7668 | var runtime2 = context.meta.runtime; |
| 7669 | var cmd = this; |
| 7670 | runtime2.nullCheck(to, this.toExpr); |
| 7671 | var result; |
| 7672 | if (this.variant === "collection") { |
| 7673 | if (Array.isArray(to)) { |
| 7674 | to.push(value); |
| 7675 | } else if (to instanceof Set) { |
| 7676 | to.add(value); |
| 7677 | } else if (to instanceof Map) { |
| 7678 | throw new Error("Use 'set myMap[key] to value' for Maps"); |
| 7679 | } else { |
| 7680 | throw new Error("Cannot add to " + typeof to); |
| 7681 | } |
| 7682 | runtime2.notifyMutation(to); |
| 7683 | return runtime2.findNext(this, context); |
| 7684 | } else if (this.variant === "class") { |
| 7685 | runtime2.forEach(classRefs, function(classRef) { |
| 7686 | if (cmd.when) { |
| 7687 | result = runtime2.implicitLoopWhen( |
| 7688 | to, |
| 7689 | cmd.when, |
| 7690 | context, |
| 7691 | function(t) { |
| 7692 | if (t instanceof Element) t.classList.add(classRef.className); |
| 7693 | }, |
| 7694 | function(t) { |
| 7695 | if (t instanceof Element) t.classList.remove(classRef.className); |
| 7696 | } |
| 7697 | ); |
| 7698 | } else { |
| 7699 | runtime2.implicitLoop(to, function(t) { |
| 7700 | if (t instanceof Element) t.classList.add(classRef.className); |
| 7701 | }); |
| 7702 | } |
| 7703 | }); |
| 7704 | } else if (this.variant === "attribute") { |
| 7705 | var attributeRef = this.attributeRef; |
| 7706 | if (this.when) { |
| 7707 | result = runtime2.implicitLoopWhen( |
| 7708 | to, |
| 7709 | this.when, |
| 7710 | context, |
| 7711 | function(t) { |
| 7712 | t.setAttribute(attributeRef.name, attributeRef.value); |
| 7713 | }, |
| 7714 | function(t) { |
| 7715 | t.removeAttribute(attributeRef.name); |
| 7716 | } |
| 7717 | ); |
| 7718 | } else { |
| 7719 | runtime2.implicitLoop(to, function(t) { |
| 7720 | t.setAttribute(attributeRef.name, attributeRef.value); |
| 7721 | }); |
| 7722 | } |
| 7723 | } else { |
| 7724 | if (this.when) { |
nothing calls this directly
no test coverage detected