1.2.1 • Published 5 years ago

@8area8/domstrict v1.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

domstrict

wrapper for the "getElement" and "querySelector" methods. Return the element or an error.

News

Add the $base parameter for query and queryAll. Todo: Create tests and update the documentation.

Installation

npm install @8area8/domstrict --save

Usage

Javascript

var get = require("@8area8/domstrict");
var $element = get.id("foo");
- Returns an HTMLElement OR throws an Error.

TypeScript

import Get from "@8area8/domstrict";
const $element = Get.queryAll(".bar");
- Returns an Array<Element> OR throws an Error.

API

class Get {
  static id(idName: string): HTMLElement;
  static class(idName: string): Element[];
  static query(selector: string): Element;
  static queryAll(selector: string): Element[];
}
/** Get an element by Id. Return the element or throw an Error. */
static id(idName: string): HTMLElement;
/** Get elements by class. Return an array or throw an Error. */
static class(className: string): Element[]
/** Get an element by query selector. Return the element or throw an Error. */
static query(selector: string): Element
/** Get an element by query selector. Return an array or throw an Error. */
static queryAll(selector: string): Element[]

Test

npm run test
1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago