@gapit/query-selector
v0.1.0
Published
A component to query html elements.
Downloads
4
Readme
@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.