(context, on, classRef, classRef2, classRefs, betweenValues)
| 8028 | return new _ToggleCommand(classRef, classRef2, classRefs, attributeRef, attributeRef2, onExpr, time, evt, from, visibility, betweenClass, betweenAttr, hideShowStrategy, betweenValues, toggleExpr, styleProp); |
| 8029 | } |
| 8030 | toggle(context, on, classRef, classRef2, classRefs, betweenValues) { |
| 8031 | if (this.betweenValues) { |
| 8032 | if (this.visibility) { |
| 8033 | context.meta.runtime.implicitLoop(on, (target) => { |
| 8034 | var current2 = target.style[this.styleProp] || getComputedStyle(target)[this.styleProp]; |
| 8035 | var idx2 = betweenValues.findIndex((v) => v == current2); |
| 8036 | target.style[this.styleProp] = betweenValues[(idx2 + 1) % betweenValues.length]; |
| 8037 | }); |
| 8038 | } else { |
| 8039 | var current = this.toggleExpr.evaluate(context); |
| 8040 | var idx = betweenValues.findIndex((v) => v == current); |
| 8041 | var next = betweenValues[(idx + 1) % betweenValues.length]; |
| 8042 | var lhsValues = {}; |
| 8043 | for (var key in this.toggleExpr.lhs) { |
| 8044 | var val = this.toggleExpr.lhs[key]; |
| 8045 | lhsValues[key] = val && val.evaluate ? val.evaluate(context) : val; |
| 8046 | } |
| 8047 | this.toggleExpr.set(context, lhsValues, next); |
| 8048 | } |
| 8049 | return; |
| 8050 | } |
| 8051 | context.meta.runtime.nullCheck(on, this.onExpr); |
| 8052 | if (this.visibility) { |
| 8053 | context.meta.runtime.implicitLoop(on, (target) => { |
| 8054 | this.hideShowStrategy("toggle", target, null, context.meta.runtime); |
| 8055 | }); |
| 8056 | } else if (this.betweenClass) { |
| 8057 | context.meta.runtime.implicitLoop(on, (target) => { |
| 8058 | if (target.classList.contains(classRef.className)) { |
| 8059 | target.classList.remove(classRef.className); |
| 8060 | target.classList.add(classRef2.className); |
| 8061 | } else { |
| 8062 | target.classList.add(classRef.className); |
| 8063 | target.classList.remove(classRef2.className); |
| 8064 | } |
| 8065 | }); |
| 8066 | } else if (this.betweenAttr) { |
| 8067 | context.meta.runtime.implicitLoop(on, (target) => { |
| 8068 | if (target.hasAttribute(this.attributeRef.name) && target.getAttribute(this.attributeRef.name) === this.attributeRef.value) { |
| 8069 | target.removeAttribute(this.attributeRef.name); |
| 8070 | target.setAttribute(this.attributeRef2.name, this.attributeRef2.value); |
| 8071 | } else { |
| 8072 | if (target.hasAttribute(this.attributeRef2.name)) target.removeAttribute(this.attributeRef2.name); |
| 8073 | target.setAttribute(this.attributeRef.name, this.attributeRef.value); |
| 8074 | } |
| 8075 | }); |
| 8076 | } else if (classRefs) { |
| 8077 | context.meta.runtime.forEach(classRefs, (classRef3) => { |
| 8078 | context.meta.runtime.implicitLoop(on, (target) => { |
| 8079 | target.classList.toggle(classRef3.className); |
| 8080 | }); |
| 8081 | }); |
| 8082 | } else { |
| 8083 | context.meta.runtime.implicitLoop(on, (target) => { |
| 8084 | if (target.hasAttribute(this.attributeRef.name)) { |
| 8085 | target.removeAttribute(this.attributeRef.name); |
| 8086 | } else { |
| 8087 | target.setAttribute(this.attributeRef.name, this.attributeRef.value); |
no test coverage detected