isDOM

说明

检查是否DOM元素

源码

用法

isDOM.test.ts
1
import { isDOM } from "../../utility/dom/isDOM";
2
3
describe('isDOM', () => {
4
test('isDOM should return `false` if received a non DOM object', () => {
5
const origin = [
6
0, Number.MAX_SAFE_INTEGER, Number.MIN_VALUE,
7
'', 'ddzy',
8
{},
9
true, false,
10
function () { },
11
[],
12
];
13
14
for (const v of origin) {
15
expect(isDOM(v)).toBeFalsy();
16
}
17
});
18
19
test('isDOM should return `true` if received a DOM object', () => {
20
const origin = [
21
document.createElement('div'),
22
document.body
23
];
24
25
for (const v of origin) {
26
expect(isDOM(v)).toBeTruthy();
27
}
28
});
29
});
Copied!
最近更新 1yr ago
复制链接