1.1.5 • Published 5 years ago

smpldm v1.1.5

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Simple DOM

Installation:

npm i --save smpldm
yarn add smpldm

Basic usage:

const {add, SmpldmElement, byID} = require("smpldm");

const input = new SmpldmElement("input", { className: "red" });
input.on("click focus", () => document.body.style.backgroundColor = "red");
input.on("blur", () => document.body.style.background = "white");

add(input).to(byID("container"));

Basic Documentation:

Creating elements
//                New Element     TagName       Attributes (note class becomes className)
const myElement = new SmpldmElement("p", { className: "body", id: "main-text" }, [data.mainText])
//                                                                               Array of Children (including plain text)
//                                                                               smpldm automagically makes text nodes
Adding event listeners (a custom Smpldm Feature)

Note, this only works on elements created with Smpldm, not regular HTML elements

// This is effectively a shorthand for .addEventListener, hence the ...options

myElement.on("click focus")
// OR 
myElement.on(["click", "focus"], callback, ...options)
Appending one element to another
add(myElement).to(parent); // Where parent and myElement can be either SmpldmElements OR regular HTMLElement's

GLHF!

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago