0.1.0 • Published 5 years ago

quelib v0.1.0

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

npm npm bundle size (minified) npm bundle size (minified + gzip) MIT ES2015+

Quelib

As all libs of this kind even this one can do:

$(()=>{/* Do on load */});

// query HTML nodes
let array = $(".query");

//access queried nodes
let node = $(".query")[0];

// and do something with its properties or methods.
$(".query").on("click", ()=>{});

However, why have a limited set of properties and methods to work with? Maybe you want others or all of them. With this lib you can get, set or call all properties or functions defined on queried nodes.

// Disable all .homeButtons
$(".homeButton").disabled = true;

// Get array of ids of buttons with .homeButton class
let array = $(".homeButton").id; 

// Assigns click event handler to all .homeButtons 
$(".homeButton").addEventListener("click", ()=>{/*e.g. Go to homepage*/});

Geting started

Install:

> npm i quelib

Import:

// with a bundler:
import $ from "quelib";

//or in Vanilla JS something like this:
import $ from "./node_modules/quelib/release/quelib.js";
//+ don't forget add type="module" to script tag in html

Or you can use source files in ./src/ to bundle & minify it yourself.

Reference

  • hide()
  • show()
  • toggle()

Aliases

addAlias(alias, property)

Predefined aliases

nameis alias of
on()addEventListener()
off()removeEventListener()

Remarks

Property lookup

By default it looks in nodes' properties first; then, if not found, it looks in prototype chain. To alter this you can:

  • Use prefixes to force one or the other behavior.

    • $ to force lookup on nodes.
    • _ to force lookup in prototype chain (= standart behavior without this lib).

      To change these call setPrefixes(noMagic, magic).

  • Call setPrefixes(noMagic, magic) with noMagic set to empty string.

Usage of proxies restrict this lib to ES2015+ environments.