tealight

WebJar for tealight

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

tealight
Последняя версия

Последняя версия

0.3.6
Дата

Дата

Тип

Тип

jar
Описание

Описание

tealight
WebJar for tealight
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/jlmakes/tealight

Скачать tealight

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/tealight/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>tealight</artifactId>
    <version>0.3.6</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/tealight/
implementation 'org.webjars.npm:tealight:0.3.6'
// https://jarcasting.com/artifacts/org.webjars.npm/tealight/
implementation ("org.webjars.npm:tealight:0.3.6")
'org.webjars.npm:tealight:jar:0.3.6'
<dependency org="org.webjars.npm" name="tealight" rev="0.3.6">
  <artifact name="tealight" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='tealight', version='0.3.6')
)
libraryDependencies += "org.webjars.npm" % "tealight" % "0.3.6"
[org.webjars.npm/tealight "0.3.6"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.webjars.npm : is-dom-node jar [1.0.4,2)
org.webjars.npm : is-dom-node-list jar [1.2.1,2)

Модули Проекта

Данный проект не имеет модулей.

Flaming tea light


Tealight

DOM queries that always return an array.

Build status Coverage Version 0.4KB min+gzip MIT License

Browser compatibility matrix



Introduction

Modern browsers enable us to perform DOM queries natively, e.g:

let cookies = document.querySelectorAll(".cookie");

But we all want to loop over the returned elements. So in practice, we’ve got to do a little more work, particularly converting the resulting NodeList to an array, e.g:

let cookies;
try {
  let query = document.querySelectorAll(".cookie");
  cookies = Array.prototype.slice.call(query);
} catch (err) {
  console.error(err.message);
}

cookies.forEach(cookie => {
  // ...
});

Tealight provides a familiar API to perform native queries, without the extra work.

tealight(".cookie").forEach(cookie => {
  // ...
});


Installation

Browser

A simple and fast way to get started is to include this script on your page:

<script src="https://unpkg.com/tealight"></script>

This will create the global variable tealight.

Module

$ npm install tealight

CommonJS

const tealight = require("tealight");

ES2015

import tealight from "tealight";


Usage

tealight accepts a single argument target and will always return an array of 0 or more DOM nodes.

For the examples below, we will query against this HTML fragment:

<div id="jar">
  <div class="chocolate-chip cookie"></div>
  <div class="peanut-butter cookie"></div>
  <div class="short-bread cookie"></div>
</div>

tealight(target: string): Array<HTMLElement>

string targets will be used as CSS selectors.

tealight("#jar");
// => [ <div#jar> ]
tealight(".cookie");
// => [ <div.chocolate-chip.cookie>, <div.peanut-butter.cookie>, <div.short-bread.cookie> ]

tealight(target: HTMLElement): Array<HTMLElement>

HTMLElement targets will simply be wrapped in an Array

const node = document.querySelector("#jar");

tealight(node);
// => [ <div#jar> ]

tealight(target: HTMLCollection) : Array<HTMLElement>

HTMLCollection arguments will be converted to Array.

const nodeList = document.querySelectorAll(".cookie");

tealight(nodeList);
// => [ <div.chocolate-chip.cookie>, <div.peanut-butter.cookie>, <div.short-bread.cookie> ]

tealight(target: Array<any>): Array<HTMLElement>

Array targets will be filtered, leaving only HTMLElement

let node = document.querySelector("#jar");
let array = [node, null, ".cookie"];

tealight(array);
// => [ <div#jar> ]



Copyright 2020 Julian Lloyd
Open source under the MIT License.

Версии библиотеки

Версия
0.3.6