0.0.4 • Published 5 years ago

@dweomercraft/runesmith v0.0.4

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

Runesmith v0.0.4

Utility functions for modifying html attributes

Install

npm install @dweomercraft/runesmith

Usage

// html
<div id="foo" class="bar" data-foo="bar">

// javascript
const Runesmith = require('@dweomercraft/runesmith');
const el = document.body.getElementById('foo');

Runesmith.removeClass(el, 'bar');
console.log(el.className); // No classes

Runesmith.addClass(el, 'foobar');
console.log(el.className); // foobar

Runesmith.get(el, 'data-foo'); // 'bar';

Runesmith.set(el, 'data-foo', 'foobar');
Runesmith.get(el, 'data-foo'); // 'foobar';

Additionally, Runesmith can assign a unique identifier to elements

Runesmith.sign(el); // Creates a data-signature attribute on el

Version Log


v0.0.4

  • Fixed an issue that caused has() to throw an error

v0.0.3

  • Added a check to ensure el argument is an instance of Element

v0.0.2

  • Signatures are generated with uuid

    v0.0.1

  • getSign() no longer attempts to call a nonexistent function