@anywhichway/lazui
Version:
Single page apps and lazy loading sites with minimal JavaScript or client build processes.
13 lines (12 loc) • 393 B
JavaScript
function dataset({el,attribute,args,lazui}) {
const {JSON} = lazui;
if(args.length===0) {
dataset = JSON.parse(attribute.value);
for (const [key, value] of Object.entries(dataset)) el.dataset[key] = value;
} else {
const key = args[0];
el.dataset[key] = attribute.value;
}
el.removeAttribute(attribute.name);
}
export {dataset}