-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
This spec doesn’t seem contain an API to parse CSS selectors.
I would like to create a function that turns a CSS selector into a HTML element. For example,
const elem = buildElem('button[type=button]#foo.bar.baz:disabled');
would do this:
const elem = document.createElement('button');
elem.setAttribute('type', 'button');
elem.id = 'foo';
elem.classList.add('bar');
elem.classList.add('baz');
elem.disabled = true;
which produces:
<button type="button" id="foo" class="bar baz" disabled></button>
For now, I would use regexes (buggy, hard to maintain) or a JS library (too much code), but it would be very nice to have a native API for selector parsing.
js-choi, zo and rgpublic
Metadata
Metadata
Assignees
Labels
No labels