(html: string, elementId: string, op: PatchOperation)
| 515 | * Apply a patch operation to an HTML source file. |
| 516 | */ |
| 517 | export function applyPatch(html: string, elementId: string, op: PatchOperation): string { |
| 518 | switch (op.type) { |
| 519 | case "inline-style": |
| 520 | return patchInlineStyle(html, elementId, op.property, op.value); |
| 521 | case "attribute": |
| 522 | return patchAttribute(html, elementId, op.property, op.value); |
| 523 | case "html-attribute": |
| 524 | return patchHtmlAttribute(html, elementId, op.property, op.value); |
| 525 | case "text-content": |
| 526 | return op.value !== null ? patchTextContent(html, elementId, op.value) : html; |
| 527 | default: |
| 528 | return html; |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | export function applyPatchByTarget(html: string, target: PatchTarget, op: PatchOperation): string { |
| 533 | if (target.id) { |
no test coverage detected