(html: string, target: PatchTarget)
| 267 | } |
| 268 | |
| 269 | export function findTagByTarget(html: string, target: PatchTarget): TagMatch | null { |
| 270 | if (target.hfId) { |
| 271 | const result = execDataAttrPattern(html, "data-hf-id", target.hfId); |
| 272 | if (result) return result; |
| 273 | } |
| 274 | |
| 275 | if (target.id) { |
| 276 | const result = execDataAttrPattern(html, "id", target.id); |
| 277 | if (result) return result; |
| 278 | } |
| 279 | |
| 280 | if (!target.selector) return null; |
| 281 | |
| 282 | const compositionIdMatch = target.selector.match(/^\[data-composition-id="([^"]+)"\]$/); |
| 283 | if (compositionIdMatch) { |
| 284 | const result = execDataAttrPattern(html, "data-composition-id", compositionIdMatch[1]); |
| 285 | if (result) return result; |
| 286 | } |
| 287 | |
| 288 | return findTagByClass(html, target); |
| 289 | } |
| 290 | |
| 291 | export function readAttributeByTarget( |
| 292 | html: string, |
no test coverage detected