mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 11:20:11 +00:00
fix: fiberkey compatibility
This commit is contained in:
parent
ba6bdda6a2
commit
fb3aea4f27
@ -4,7 +4,7 @@ import { host } from './host';
|
||||
import SimulatorRendererView from './renderer-view';
|
||||
import { computed, observable as obx, untracked, makeObservable, configure } from 'mobx';
|
||||
import { getClientRects } from './utils/get-client-rects';
|
||||
import { reactFindDOMNodes, FIBER_KEY } from './utils/react-find-dom-nodes';
|
||||
import { reactFindDOMNodes, getReactInternalFiber } from './utils/react-find-dom-nodes';
|
||||
import {
|
||||
Asset,
|
||||
isElement,
|
||||
@ -565,7 +565,7 @@ function getClosestNodeInstance(
|
||||
if (isElement(el)) {
|
||||
el = cacheReactKey(el);
|
||||
} else {
|
||||
return getNodeInstance(el[FIBER_KEY], specId);
|
||||
return getNodeInstance(getReactInternalFiber(el), specId);
|
||||
}
|
||||
}
|
||||
while (el) {
|
||||
|
||||
@ -3,7 +3,9 @@ import { findDOMNode } from 'react-dom';
|
||||
import { isElement } from '@alilc/lowcode-utils';
|
||||
import { isDOMNode } from './is-dom-node';
|
||||
|
||||
export const FIBER_KEY = '_reactInternalFiber';
|
||||
export const getReactInternalFiber = (el: any) => {
|
||||
return el._reactInternals || el._reactInternalFiber;
|
||||
};
|
||||
|
||||
function elementsFromFiber(fiber: any, elements: Array<Element | Text>) {
|
||||
if (fiber) {
|
||||
@ -28,7 +30,7 @@ export function reactFindDOMNodes(elem: ReactInstance | null): Array<Element | T
|
||||
return [elem];
|
||||
}
|
||||
const elements: Array<Element | Text> = [];
|
||||
const fiberNode = (elem as any)[FIBER_KEY];
|
||||
const fiberNode = getReactInternalFiber(elem);
|
||||
elementsFromFiber(fiberNode?.child, elements);
|
||||
if (elements.length > 0) return elements;
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user