Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
DOM queries that always return an array.
Modern browsers enable us to perform DOM queries natively, e.g:
let cookies = document.querySelectorAll(".cookie");
But we all want to look 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 => {
// ...
});
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
.
$ npm install tealight
const tealight = require("tealight");
import tealight from "tealight";
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 2018 Fisssion LLC.
Open source under the MIT License.
[0.3.3] - 2018-08-10
FAQs
DOM queries that always return an array
The npm package tealight receives a total of 6,812 weekly downloads. As such, tealight popularity was classified as popular.
We found that tealight demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.