setAttr

说明

设置单个DOM属性

源码

用法

setAttr.test.ts
1
import { setAttr } from "../../utility/dom/setAttr";
2
3
describe('setAttr', () => {
4
test('setAttr should receive a DOM object and attributes, add attributes to DOM, and return nothing', () => {
5
document.body.innerHTML = `
6
<input id="text"></div>
7
`;
8
9
expect(setAttr(
10
document.getElementById('text') as HTMLElement,
11
{
12
class: 'text',
13
type: 'text',
14
}
15
));
16
});
17
});
Copied!
最近更新 1yr ago
复制链接