1.0.2 • Published 2 years ago

@alexspirgel/normalize-elements v1.0.2

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

Normalize Elements

A utility function that returns an array of element references from a variety of argument types.

Valid argument types include:

  • element reference
  • css selector string
  • query selectors (document.querySelector, document.querySelectorAll, or any node list)
  • an array including any combination of the above

Installation

Using NPM:

npm install @alexspirgel/normalize-elements
const normalizeElements = require('@alexspirgel/normalize-elements');

Usage

let elements = normalizeElements(document.body); // element reference
let elements = normalizeElements('.example-selector'); // css selector string
let elements = normalizeElements(document.querySelectorAll('.another-selector')); // query selector (node list)
let elements = normalizeElements([ // an array including any combination of the above.
	document.body,
	'.example-selector',
	document.querySelectorAll('.another-selector')
]);