@gapit/query-selector
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@gapit/query-selector

This component's function is to query for html elements. It contains both certain and uncertain methods.

querySelector

import { querySelector, querySelectorUnsafe } from "@gapit/query-selector";

const element = querySelector<SVGElement>(`#some-element`);
//  returns an element of given type, if element does not exist it throws an error.

const opt = querySelector<SVGElement>(`text`, element);
//  query existing element

const unsafeElement = querySelectorUnsafe<SVGElement>(`#some-element`);
//  returns a element of given type, if element does not exist return null.

queryGroupPosition

import { querySelector, queryGroupPosition } from "@gapit/query-selector";

const element = queryGroupPosition<SVGElement>(
  querySelector(`#some-element`),
  0
);
//  returns child element of given element, if element does not exist it throws an error.

const unsafeElement = queryGroupPositionUnsafe<SVGElement>(
  querySelector(`#some-element`),
  0
);
//  returns child element of given element, if element does not exist return null.

queryGroupPositionBySelector

import { queryGroupPositionBySelector } from "@gapit/query-selector";

const element = queryGroupPositionBySelector<SVGElement>(`#some-element`, 0);
//  returns child element of given query at given position, if element does not exist it throws an error.

querySelectorAll

import {
  querySelector,
  querySelectorAll,
  querySelectorAllUnsafe,
} from "@gapit/query-selector";

const element = querySelectorAll<SVGElement>(`text`);
//  returns all text elements as a node list.

const opt = querySelector<SVGGElement>(`#some-element`);
const queryExisting = querySelectorAll<SVGRectElement>(`[rect]`, opt);
//  returns all rect elements within given element.

const unsafeElement = querySelectorAllUnsafe<SVGElement>(`path`);
//  returns all elements of given selector, if no element fits the selector return null.

Readme

Keywords

none

Package Sidebar

Install

npm i @gapit/query-selector

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

27 kB

Total Files

16

Last publish

Collaborators

  • ulberg
  • sverret
  • flesa
  • mjos
  • oklk
  • zuperzee