GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: fiberkey compatibility · bruceywave/lowcode-engine@fb3aea4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-simulator-renderer/src
    • renderer.ts
    • utils
      • react-find-dom-nodes.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-simulator-renderer/src/renderer.ts‎

Copy file name to clipboardExpand all lines: packages/react-simulator-renderer/src/renderer.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { host } from './host';
44
import SimulatorRendererView from './renderer-view';
55
import { computed, observable as obx, untracked, makeObservable, configure } from 'mobx';
66
import { getClientRects } from './utils/get-client-rects';
7-
import { reactFindDOMNodes, FIBER_KEY } from './utils/react-find-dom-nodes';
7+
import { reactFindDOMNodes, getReactInternalFiber } from './utils/react-find-dom-nodes';
88
import {
99
Asset,
1010
isElement,
@@ -565,7 +565,7 @@ function getClosestNodeInstance(
565565
if (isElement(el)) {
566566
el = cacheReactKey(el);
567567
} else {
568-
return getNodeInstance(el[FIBER_KEY], specId);
568+
return getNodeInstance(getReactInternalFiber(el), specId);
569569
}
570570
}
571571
while (el) {
Collapse file

‎packages/react-simulator-renderer/src/utils/react-find-dom-nodes.ts‎

Copy file name to clipboardExpand all lines: packages/react-simulator-renderer/src/utils/react-find-dom-nodes.ts
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { findDOMNode } from 'react-dom';
33
import { isElement } from '@alilc/lowcode-utils';
44
import { isDOMNode } from './is-dom-node';
55

6-
export const FIBER_KEY = '_reactInternalFiber';
6+
export const getReactInternalFiber = (el: any) => {
7+
return el._reactInternals || el._reactInternalFiber;
8+
};
79

810
function elementsFromFiber(fiber: any, elements: Array<Element | Text>) {
911
if (fiber) {
@@ -28,7 +30,7 @@ export function reactFindDOMNodes(elem: ReactInstance | null): Array<Element | T
2830
return [elem];
2931
}
3032
const elements: Array<Element | Text> = [];
31-
const fiberNode = (elem as any)[FIBER_KEY];
33+
const fiberNode = getReactInternalFiber(elem);
3234
elementsFromFiber(fiberNode?.child, elements);
3335
if (elements.length > 0) return elements;
3436
try {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.