(command, newCode)
| 158 | }; |
| 159 | |
| 160 | const rewrite = function (command, newCode) { |
| 161 | const parent = command.cmd.parent; |
| 162 | let prev; |
| 163 | for (prev of parent.children) { |
| 164 | if (prev.next === command.cmd) break; |
| 165 | } |
| 166 | const next = command.next; |
| 167 | |
| 168 | const tok = _hyperscript.internals.tokenizer.tokenize(newCode); |
| 169 | const parser = _hyperscript.internals.createParser(tok); |
| 170 | const newcmd = parser.requireElement("command"); |
| 171 | |
| 172 | newcmd.startToken = command.startToken; |
| 173 | newcmd.endToken = command.endToken; |
| 174 | newcmd.programSource = command.programSource; |
| 175 | newcmd.sourceFor = function () { |
| 176 | return newCode; |
| 177 | }; |
| 178 | |
| 179 | prev.next = newcmd; |
| 180 | newcmd.next = next; |
| 181 | newcmd.parent = parent; |
| 182 | |
| 183 | bus.dispatchEvent(new Event("step")); |
| 184 | }; |
| 185 | |
| 186 | const logCommand = function () { |
| 187 | const hasSource = cmd.sourceFor instanceof Function; |
nothing calls this directly
no test coverage detected