| 148 | }, |
| 149 | |
| 150 | toggle(className, force) { |
| 151 | if (typeof className !== 'string') return false |
| 152 | |
| 153 | className = className.trim() |
| 154 | |
| 155 | if (!className) return false |
| 156 | |
| 157 | const isNotContain = this.indexOf(className) === -1 |
| 158 | let action = isNotContain ? 'add' : 'remove' |
| 159 | action = force === true ? 'add' : force === false ? 'remove' : action |
| 160 | |
| 161 | if (action === 'add') { |
| 162 | this.add(className) |
| 163 | } else { |
| 164 | this.remove(className) |
| 165 | } |
| 166 | |
| 167 | return force === true || force === false ? force : isNotContain |
| 168 | }, |
| 169 | |
| 170 | toString() { |
| 171 | return this.join(' ') |