Skip to content

Commit

Permalink
chore: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxh16144 committed May 20, 2024
1 parent 2d90b87 commit 6a982e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Dom/findDOMNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function isDOM(node: any): node is HTMLElement | SVGElement {
/**
* Retrieves a DOM node via a ref, and does not invoke `findDOMNode`.
*/
export function getDomNode(node: any): node is HTMLElement | SVGElement {
export function getDOM(node: any): node is HTMLElement | SVGElement {
if (node && typeof node === 'object' && isDOM(node.nativeElement)) {
return node.nativeElement;
}
Expand All @@ -28,7 +28,7 @@ export function getDomNode(node: any): node is HTMLElement | SVGElement {
export default function findDOMNode<T = Element | Text>(
node: React.ReactInstance | HTMLElement | SVGElement | { nativeElement: T },
): T {
const domNode = getDomNode(node);
const domNode = getDOM(node);
if (domNode) {
return domNode as T;
}
Expand Down
10 changes: 5 additions & 5 deletions tests/findDOMNode.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render } from '@testing-library/react';
import * as React from 'react';
import findDOMNode, { getDomNode, isDOM } from '../src/Dom/findDOMNode';
import findDOMNode, { getDOM, isDOM } from '../src/Dom/findDOMNode';
import proxyObject from '../src/proxyObject';

describe('findDOMNode', () => {
Expand Down Expand Up @@ -130,10 +130,10 @@ describe('findDOMNode', () => {
);
});

describe('getDomNode', () => {
describe('getDOM', () => {
it('should return the DOM node when input is a DOM node', () => {
const node = document.createElement('div');
const result = getDomNode(node);
const result = getDOM(node);

expect(result).toBe(node);
});
Expand All @@ -142,15 +142,15 @@ describe('findDOMNode', () => {
const nativeElement = document.createElement('div');
const node = { nativeElement };

const result = getDomNode(node);
const result = getDOM(node);

expect(result).toBe(nativeElement);
});

it.each([null, void 0, { foo: 'bar' }, 'string'])(
'should return null when input is not a DOM node',
node => {
const result = getDomNode(node);
const result = getDOM(node);

expect(result).toBeNull();
},
Expand Down

0 comments on commit 6a982e3

Please sign in to comment.