setCss

说明

设置单个DOM样式

源码

用法

setCss.test.ts
1
import { setCss } from "../../utility/dom/setCss";
2
3
describe('setCss', () => {
4
test('setCss should receive a DOM object and CSS Rule options, add rules to DOM.', () => {
5
document.body.innerHTML = `
6
<div id="app">app</div>
7
`;
8
9
setCss(
10
document.getElementById('app') as HTMLElement,
11
{
12
color: 'red',
13
'font-size': 25,
14
},
15
);
16
17
expect((document.getElementById('app') as HTMLElement).getAttribute('style')).toBe('color: red; font-size: 25;');
18
19
});
20
});
Copied!
最近更新 1yr ago
复制链接