insertionState.ts 663 B

12345678910111213141516171819202122232425
  1. export let insertionParent:
  2. | (ParentNode & {
  3. $pa?: Node
  4. $ia?: Node
  5. $aa?: Node
  6. })
  7. | undefined
  8. export let insertionAnchor: Node | 0 | undefined | null
  9. /**
  10. * This function is called before a block type that requires insertion
  11. * (component, slot outlet, if, for) is created. The state is used for actual
  12. * insertion on client-side render, and used for node adoption during hydration.
  13. */
  14. export function setInsertionState(
  15. parent: ParentNode,
  16. anchor?: Node | 0 | null,
  17. ): void {
  18. insertionParent = parent
  19. insertionAnchor = anchor
  20. }
  21. export function resetInsertionState(): void {
  22. insertionParent = insertionAnchor = undefined
  23. }