(parsed: ParsedDocument, ids: HfId[], value: string)
| 351 | } |
| 352 | |
| 353 | function handleSetText(parsed: ParsedDocument, ids: HfId[], value: string): MutationResult { |
| 354 | const result: MutationResult = { forward: [], inverse: [] }; |
| 355 | for (const id of ids) { |
| 356 | const el = resolveScoped(parsed.document, id); |
| 357 | if (!el) continue; |
| 358 | const oldText = getOwnText(el); |
| 359 | setOwnText(el, value); |
| 360 | const path = textPath(id); |
| 361 | // getOwnText always returns string ("" for empty) — use it directly so |
| 362 | // the forward patch is always op:'replace', not op:'add'. An op:'add' on |
| 363 | // a text path is semantically wrong for external JSON-patch consumers |
| 364 | // (the path already exists; add would fail on strict appliers). |
| 365 | const p = scalarChange(path, oldText, value); |
| 366 | result.forward.push(p.forward); |
| 367 | result.inverse.push(p.inverse); |
| 368 | } |
| 369 | return result; |
| 370 | } |
| 371 | |
| 372 | function handleSetAttribute( |
| 373 | parsed: ParsedDocument, |
no test coverage detected