(html: string, target: PatchTarget, op: PatchOperation)
| 530 | } |
| 531 | |
| 532 | export function applyPatchByTarget(html: string, target: PatchTarget, op: PatchOperation): string { |
| 533 | if (target.id) { |
| 534 | const patchedById = applyPatch(html, target.id, op); |
| 535 | if (patchedById !== html || !target.selector) { |
| 536 | return patchedById; |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | switch (op.type) { |
| 541 | case "inline-style": |
| 542 | return patchInlineStyleByTarget(html, target, op.property, op.value); |
| 543 | case "attribute": |
| 544 | return patchAttributeByTarget(html, target, op.property, op.value); |
| 545 | case "html-attribute": |
| 546 | return patchHtmlAttributeByTarget(html, target, op.property, op.value); |
| 547 | case "text-content": |
| 548 | return op.value !== null ? patchTextContentByTarget(html, target, op.value) : html; |
| 549 | default: |
| 550 | return html; |
| 551 | } |
| 552 | } |
no test coverage detected