Additional to @yamato-daiwa/es-extensions functionality for the browser environment.
Helper functions and classes aimed to reduce the routine code.
Build-in TypeScript type safety without any type.
Oriented to TypeScript users investing the time to quality including type-safety.
npm i @yamato-daiwa/es-extensions-browserjs @yamato-daiwa/es-extensions -E
Please install the same versions of the above dependencies.
- cloneDOM_Element
- Clones target DOM element herewith takes care about dealing with correct typing of a cloned element. It is required to explicitly specify must children nodes be cloned at once.
- createDOM_ElementFromHTML_Code
- Creates the DOM element (Element) or it's inheritor from HTML code, herewith it must be exactly one root element.
- createHTML_CollectionFromHTML_Code
- Creates the HTMLCollection from HTML code passed as parameter.
- getExpectedToBeSingleChildOfTemplateElement
- Retrieves the child (of Element type or specified subtype) of template element if this child is exactly one, otherwise throws the error.
- getExpectedToBeSingleDOM_Element
- Retrieves the element corresponding to specified selector if this element presents in single instance inside specific context, otherwise throws the error.
- addLeftClickEventHandler
-
Adds on mouse left click event handler.
The main difference with native analogues is
addLeftClickEventHandlerprovides the instance of MouseEvent, not genericEventthat is critical for TypeScript. - delegateClickEventHandling
- Creates just one click event listener while allowing to handle the click of arbitrary large number of elements what is the optimization measures.
- BasicFrontEndLogger
- The implementation of ILogger interface for the Logger facade which could be used as the base of the custom implementation for the frontend side of the websites / web application.