Skip to content

WebReflection/qs2el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qs2el

Social Media Photo by Matheus Frade on Unsplash

Build Status Coverage Status WebReflection status

Create an element from a query selector string.

// as function
const a = qs2el('a#home.special[data-page=home]');

// or as literal
const button = qs2el`button${'.primary'}[disabled]`;

The exported function also have an .escape(value) to safely parse text that might contain [ or ] chars.

const value = 'this [might] be an issue';
const div = qs2el`div[data-blob=${qs2el.escape(value)}]`;

div.dataset.blob === value; // true

About

Create elements from query selector strings.

Resources

License

Stars

Watchers

Forks

Packages

No packages published