跳到主要内容

React fiber config with no test selectors

一、作用

不支持测试选择器的渲染器可以从此模块重新导出所有内容

二、导出的常量

不支持测试选择器的渲染器可以从此模块重新导出所有内容

1. 支持测试选择器

备注

源码中 21 - 22 行

// Test selectors (when unsupported)
// 测试选择器(当不支持时)
export const supportsTestSelectors = false;

2. 查找 Fiber 根

备注

源码中 23 行

export const findFiberRoot = shim;

3. 获取边界矩形

备注

源码中 24 行

export const getBoundingRect = shim;

4. 获取文本内容

备注

源码中 25 行

export const getTextContent = shim;

5. 判定是否为隐藏子树

备注

源码中 26 行

export const isHiddenSubtree = shim;

6. 匹配可访问性角色

备注

源码中 27 行

export const matchAccessibilityRole = shim;

7. 如果可聚焦则设置焦点

备注

源码中 28 行

export const setFocusIfFocusable = shim;

8. 设置交叉观察器

备注

源码中 29 行

export const setupIntersectionObserver = shim;

三、工具

1. 兼容垫片

// Renderers that don't support test selectors
// can re-export everything from this module.
// 不支持测试选择器的渲染器可以从此模块重新导出所有内容

function shim(...args: any): empty {
throw new Error(
'The current renderer does not support test selectors. ' +
'This error is likely caused by a bug in React. ' +
'Please file an issue.',
);
}