mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
dom: h should allow ids and multiple class names (#155311)
This commit is contained in:
parent
f485d5e987
commit
05d1f4a5ee
|
@ -1788,10 +1788,21 @@ export function h(tag: string, ...args: [] | [attributes: { $: string } & DomNod
|
|||
children = args[1];
|
||||
}
|
||||
|
||||
const [tagName, className] = tag.split('.');
|
||||
const match = SELECTOR_REGEX.exec(tag);
|
||||
|
||||
if (!match) {
|
||||
throw new Error('Bad use of h');
|
||||
}
|
||||
|
||||
const tagName = match[1] || 'div';
|
||||
const el = document.createElement(tagName);
|
||||
if (className) {
|
||||
el.className = className;
|
||||
|
||||
if (match[3]) {
|
||||
el.id = match[3];
|
||||
}
|
||||
|
||||
if (match[4]) {
|
||||
el.className = match[4].replace(/\./g, ' ').trim();
|
||||
}
|
||||
|
||||
const result: Record<string, HTMLElement> = {};
|
||||
|
|
Loading…
Reference in a new issue