mirror of
https://github.com/BloopAI/vibe-kanban-web-companion.git
synced 2026-08-23 11:58:32 +00:00
@@ -1,5 +1,5 @@
|
||||
import { getReactInstanceForElement } from './getReactInstanceForElement.js'
|
||||
import { getSourceForInstance } from './getSourceForInstance.js'
|
||||
import { getReactInstanceForElement } from './getReactInstanceForElement'
|
||||
import { getSourceForInstance } from './getSourceForInstance'
|
||||
|
||||
/**
|
||||
* @typedef {import('react-reconciler').Fiber} Fiber
|
||||
@@ -16,5 +16,17 @@ export function getSourceForElement(
|
||||
|
||||
if (source) return source
|
||||
|
||||
console.warn("Couldn't find a React instance for the element", element)
|
||||
const fallbackSource = getFirstParentElementWithSource(element)
|
||||
return fallbackSource
|
||||
}
|
||||
|
||||
function getFirstParentElementWithSource(element) {
|
||||
const parentElement = element.parentElement
|
||||
if (parentElement === null) throw new Error('No parent found')
|
||||
|
||||
const instance = getReactInstanceForElement(parentElement)
|
||||
const source = getSourceForInstance(instance)
|
||||
|
||||
if (source) return source
|
||||
else return getFirstParentElementWithSource(element)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user