1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-01 15:54:25 +00:00
gitea/web_src/js/utils/dom.test.ts
wxiaoguang e3678356e1
Fix createElementFromAttrs bug (#31751)
The "false" value was not handled correctly, it would cause bugs in the
future (fortunately, this behavior is not used in code yet).
2024-08-01 19:06:03 +00:00

19 lines
603 B
TypeScript

import {createElementFromAttrs, createElementFromHTML} from './dom.ts';
test('createElementFromHTML', () => {
expect(createElementFromHTML('<a>foo<span>bar</span></a>').outerHTML).toEqual('<a>foo<span>bar</span></a>');
});
test('createElementFromAttrs', () => {
const el = createElementFromAttrs('button', {
id: 'the-id',
class: 'cls-1 cls-2',
'data-foo': 'the-data',
disabled: true,
checked: false,
required: null,
tabindex: 0,
});
expect(el.outerHTML).toEqual('<button id="the-id" class="cls-1 cls-2" data-foo="the-data" disabled="" tabindex="0"></button>');
});