1.0.0-alpha.2 • Published 3 years ago

@tamb/utils v1.0.0-alpha.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

@tamb./utils

Utils I use

createElement

a simple create element function

Installation

import {createElement} from "@tamb/utils";

Usage

createElement({
    type: "div",
    text: "My text",
    attributes: [["id", "yoyo"], ["classes": ["my", "many", "classes"]]],
    children: {
        ...repeat
    },
    ref: "myRefName"
})

refs

If you use .call and bind to an object you can create a ref as a field name in that object

const x = {};

createElement.call(x, {
    type: "div",
    ref: "hey"
});

x.hey// will be your div

inserting

document.body.appendElement(createElement({type: "div"}));