Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Oct 8, 2019
1 parent bfa5eaf commit 91616c9
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 36 deletions.
8 changes: 4 additions & 4 deletions packages/react-interactions/accessibility/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function MyComponent(props) {
);
}

// Using the ref, we can get the host nodes via getAllScopedNodes()
const divs = divOnlyScope.current.getAllScopedNodes();
// Using the ref, we can get the host nodes via getAllNodes()
const divs = divOnlyScope.current.getAllNodes();

// [<div>DIV 1</div>, <div>DIV 2</div>, <div>DIV 3</div>]
console.log(divs);
Expand Down Expand Up @@ -72,12 +72,12 @@ Returns the parent `ReactScopeInterface` of the scope node or `null` if none exi

Returns the current `props` object of the scope node.

### getAllScopedNodes: () => null | Array<HTMLElement>
### getAllNodes: () => null | Array<HTMLElement>

Returns an array of all child host nodes that successfully match when queried using the
query function passed to the scope. Returns `null` if there are no matching host nodes.

### getFirstScopedNode: () => null | HTMLElement
### getFirstNode: () => null | HTMLElement

Returns the first child host node that successfully matches when queried using the
query function passed to the scope. Returns `null` if there is no matching host node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function FocusableNodeCollector(props) {
const scope = scopeRef.current;

if (scope) {
const tabFocusableNodes = scope.getAllScopedNodes();
const tabFocusableNodes = scope.getAllNodes();
if (tabFocusableNodes && props.onFocusableNodes) {
props.onFocusableNodes(tabFocusableNodes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function FocusContain({
disabled !== true &&
!scope.containsNode(document.activeElement)
) {
const fistElem = scope.getFirstScopedNode();
const fistElem = scope.getFirstNode();
if (fistElem !== null) {
fistElem.focus();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-interactions/accessibility/src/FocusGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type FocusGroupProps = {|
const {useRef} = React;

function focusGroupItem(cell: ReactScopeMethods, event: KeyboardEvent): void {
const firstScopedNode = cell.getFirstScopedNode();
const firstScopedNode = cell.getFirstNode();
if (firstScopedNode !== null) {
firstScopedNode.focus();
event.preventDefault();
Expand Down Expand Up @@ -135,7 +135,7 @@ export function createFocusGroup(
const tabScope = getGroupProps(currentItem).tabScopeRef.current;
if (tabScope) {
const activeNode = document.activeElement;
const nodes = tabScope.getAllScopedNodes();
const nodes = tabScope.getAllNodes();
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
if (node !== activeNode) {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-interactions/accessibility/src/FocusTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type FocusTableProps = {|
const {useRef} = React;

function focusScope(cell: ReactScopeMethods, event?: KeyboardEvent): void {
const firstScopedNode = cell.getFirstScopedNode();
const firstScopedNode = cell.getFirstNode();
if (firstScopedNode !== null) {
firstScopedNode.focus();
if (event) {
Expand Down Expand Up @@ -209,7 +209,7 @@ export function createFocusTable(
const tabScope = getTableProps(currentCell).tabScopeRef.current;
if (tabScope) {
const activeNode = document.activeElement;
const nodes = tabScope.getAllScopedNodes();
const nodes = tabScope.getAllNodes();
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
if (node !== activeNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('TabbableScope', () => {
container = null;
});

it('getAllScopedNodes() works as intended', () => {
it('getAllNodes() works as intended', () => {
const scopeRef = React.createRef();
const nodeRefA = React.createRef();
const nodeRefB = React.createRef();
Expand All @@ -58,7 +58,7 @@ describe('TabbableScope', () => {
}

ReactDOM.render(<Test />, container);
let nodes = scopeRef.current.getAllScopedNodes();
let nodes = scopeRef.current.getAllNodes();
expect(nodes).toEqual([
nodeRefA.current,
nodeRefB.current,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function getTabbableNodes(
number,
null | HTMLElement,
] {
const tabbableNodes = scope.getAllScopedNodes();
const tabbableNodes = scope.getAllNodes();
if (tabbableNodes === null || tabbableNodes.length === 0) {
return [null, null, null, 0, null];
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export function createScopeMethods(
const currentFiber = ((instance.fiber: any): Fiber);
return currentFiber.memoizedProps;
},
getAllScopedNodes(): null | Array<Object> {
getAllNodes(): null | Array<Object> {
const currentFiber = ((instance.fiber: any): Fiber);
const child = currentFiber.child;
const scopedNodes = [];
Expand All @@ -198,7 +198,7 @@ export function createScopeMethods(
}
return scopedNodes.length === 0 ? null : scopedNodes;
},
getFirstScopedNode(): null | Object {
getFirstNode(): null | Object {
const currentFiber = ((instance.fiber: any): Fiber);
const child = currentFiber.child;
if (child !== null) {
Expand Down
38 changes: 19 additions & 19 deletions packages/react-reconciler/src/__tests__/ReactScope-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('ReactScope', () => {
container = null;
});

it('getAllScopedNodes() works as intended', () => {
it('getAllNodes() works as intended', () => {
const TestScope = React.unstable_createScope((type, props) => true);
const scopeRef = React.createRef();
const divRef = React.createRef();
Expand All @@ -62,16 +62,16 @@ describe('ReactScope', () => {
}

ReactDOM.render(<Test toggle={true} />, container);
let nodes = scopeRef.current.getAllScopedNodes();
let nodes = scopeRef.current.getAllNodes();
expect(nodes).toEqual([divRef.current, spanRef.current, aRef.current]);
ReactDOM.render(<Test toggle={false} />, container);
nodes = scopeRef.current.getAllScopedNodes();
nodes = scopeRef.current.getAllNodes();
expect(nodes).toEqual([aRef.current, divRef.current, spanRef.current]);
ReactDOM.render(null, container);
expect(scopeRef.current).toBe(null);
});

it('getFirstScopedNode() works as intended', () => {
it('getFirstNode() works as intended', () => {
const TestScope = React.unstable_createScope((type, props) => true);
const scopeRef = React.createRef();
const divRef = React.createRef();
Expand All @@ -95,10 +95,10 @@ describe('ReactScope', () => {
}

ReactDOM.render(<Test toggle={true} />, container);
let node = scopeRef.current.getFirstScopedNode();
let node = scopeRef.current.getFirstNode();
expect(node).toEqual(divRef.current);
ReactDOM.render(<Test toggle={false} />, container);
node = scopeRef.current.getFirstScopedNode();
node = scopeRef.current.getFirstNode();
expect(node).toEqual(aRef.current);
ReactDOM.render(null, container);
expect(scopeRef.current).toBe(null);
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('ReactScope', () => {
expect(scopeRef.current.containsNode(emRef.current)).toBe(false);
});

it('mixed getParent() and getAllScopedNodes() works as intended', () => {
it('mixed getParent() and getAllNodes() works as intended', () => {
const TestScope = React.unstable_createScope((type, props) => true);
const TestScope2 = React.unstable_createScope((type, props) => true);
const refA = React.createRef();
Expand Down Expand Up @@ -190,14 +190,14 @@ describe('ReactScope', () => {
ReactDOM.render(<Test />, container);
const dParent = refD.current.getParent();
expect(dParent).not.toBe(null);
expect(dParent.getAllScopedNodes()).toEqual([
expect(dParent.getAllNodes()).toEqual([
divA.current,
spanB.current,
divB.current,
]);
const cParent = refC.current.getParent();
expect(cParent).not.toBe(null);
expect(cParent.getAllScopedNodes()).toEqual([
expect(cParent.getAllNodes()).toEqual([
spanA.current,
divA.current,
spanB.current,
Expand Down Expand Up @@ -278,7 +278,7 @@ describe('ReactScope', () => {
);
container.innerHTML = html;
ReactDOM.hydrate(<Test />, container);
const nodes = scopeRef.current.getAllScopedNodes();
const nodes = scopeRef.current.getAllNodes();
expect(nodes).toEqual([divRef.current, spanRef.current, aRef.current]);
});

Expand Down Expand Up @@ -332,7 +332,7 @@ describe('ReactScope', () => {
ReactTestRenderer = require('react-test-renderer');
});

it('getAllScopedNodes() works as intended', () => {
it('getAllNodes() works as intended', () => {
const TestScope = React.unstable_createScope((type, props) => true);
const scopeRef = React.createRef();
const divRef = React.createRef();
Expand Down Expand Up @@ -360,14 +360,14 @@ describe('ReactScope', () => {
return element;
},
});
let nodes = scopeRef.current.getAllScopedNodes();
let nodes = scopeRef.current.getAllNodes();
expect(nodes).toEqual([divRef.current, spanRef.current, aRef.current]);
renderer.update(<Test toggle={false} />);
nodes = scopeRef.current.getAllScopedNodes();
nodes = scopeRef.current.getAllNodes();
expect(nodes).toEqual([aRef.current, divRef.current, spanRef.current]);
});

it('getFirstScopedNode() works as intended', () => {
it('getFirstNode() works as intended', () => {
const TestScope = React.unstable_createScope((type, props) => true);
const scopeRef = React.createRef();
const divRef = React.createRef();
Expand Down Expand Up @@ -395,14 +395,14 @@ describe('ReactScope', () => {
return element;
},
});
let node = scopeRef.current.getFirstScopedNode();
let node = scopeRef.current.getFirstNode();
expect(node).toEqual(divRef.current);
renderer.update(<Test toggle={false} />);
node = scopeRef.current.getFirstScopedNode();
node = scopeRef.current.getFirstNode();
expect(node).toEqual(aRef.current);
});

it('mixed getParent() and getAllScopedNodes() works as intended', () => {
it('mixed getParent() and getAllNodes() works as intended', () => {
const TestScope = React.unstable_createScope((type, props) => true);
const TestScope2 = React.unstable_createScope((type, props) => true);
const refA = React.createRef();
Expand Down Expand Up @@ -443,14 +443,14 @@ describe('ReactScope', () => {
});
const dParent = refD.current.getParent();
expect(dParent).not.toBe(null);
expect(dParent.getAllScopedNodes()).toEqual([
expect(dParent.getAllNodes()).toEqual([
divA.current,
spanB.current,
divB.current,
]);
const cParent = refC.current.getParent();
expect(cParent).not.toBe(null);
expect(cParent.getAllScopedNodes()).toEqual([
expect(cParent.getAllNodes()).toEqual([
spanA.current,
divA.current,
spanB.current,
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/ReactTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ export type ReactScopeMethods = {|
getChildrenFromRoot(): null | Array<ReactScopeMethods>,
getParent(): null | ReactScopeMethods,
getProps(): Object,
getAllScopedNodes(): null | Array<Object>,
getFirstScopedNode(): null | Object,
getAllNodes(): null | Array<Object>,
getFirstNode(): null | Object,
containsNode(Object): boolean,
|};

Expand Down

0 comments on commit 91616c9

Please sign in to comment.