tamb / tamb-utils

random utils I like to use

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@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"}));

About

random utils I like to use


Languages

Language:SCSS 41.2%Language:TypeScript 33.9%Language:JavaScript 20.5%Language:HTML 4.3%