attribute-analyzer
Parse complex attributes on the server with ease
import { EmptyAttribute,analyze,getLocalName } from "attribute-analyzer"
const input = `<button on:click={() => {value++}} test="yes" :data>testing</button>`;
const name = getLocalName(input);
const analyzedElement = analyze(input);
const isEmpty = analyzedElement.element.attributes[":data"] instanceof EmptyAttribute
attributes.addAttribute({"name": "on:mouseover", "value": `{() => alert("hey")}`})
console.log(attributes.element.rawElement)
attributes.removeAttribute("on:mouseover")
console.log(attributes.element.rawElement)
Installation
npm install attribute-analyzer
Features
👻 0 dependencies
😎 Fast
🐱👤 Ability to parse complex attributes
License
MIT