(props: DiffProps<T>)
| 10 | // |
| 11 | |
| 12 | export function Diff<T>(props: DiffProps<T>) { |
| 13 | let container!: HTMLDivElement |
| 14 | const [local, others] = splitProps(props, ["before", "after", "class", "classList", "annotations"]) |
| 15 | |
| 16 | const fileDiff = createMemo( |
| 17 | () => |
| 18 | new FileDiff<T>( |
| 19 | { |
| 20 | ...createDefaultOptions(props.diffStyle), |
| 21 | ...others, |
| 22 | }, |
| 23 | workerPool, |
| 24 | ), |
| 25 | ) |
| 26 | |
| 27 | const cleanupFunctions: Array<() => void> = [] |
| 28 | |
| 29 | createEffect(() => { |
| 30 | container.innerHTML = "" |
| 31 | fileDiff().render({ |
| 32 | oldFile: local.before, |
| 33 | newFile: local.after, |
| 34 | lineAnnotations: local.annotations, |
| 35 | containerWrapper: container, |
| 36 | }) |
| 37 | }) |
| 38 | |
| 39 | onCleanup(() => { |
| 40 | // Clean up FileDiff event handlers and dispose SolidJS components |
| 41 | fileDiff()?.cleanUp() |
| 42 | cleanupFunctions.forEach((dispose) => dispose()) |
| 43 | }) |
| 44 | |
| 45 | return <div data-component="diff" style={styleVariables} ref={container} /> |
| 46 | } |
nothing calls this directly
no test coverage detected