Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@appstractdk/as-core

greta_appstract32ISC1.1.18

as-core contains the base for most of our components, i.e. Base and View components. This packages contains no styling.

readme

as-core

as-core contains the base for most of our components, i.e. Base and View components. This packages contains no styling.

Base

Base class contains the following methods:

  • makeElement(name[, attributes]) - creates HTML element specified by tagName with optional attributes.

    • const node = this.makeElement('div', 'test-class'); - creates an element with a class passed as a string.
    • const node = this.makeElement('div', 'test-class another-test-class third-class'); - creates an element with several classes passed as a string.
    • `const node = this..makeElement('div', {

            className: 'test-class',
        }, [
            this.makeElement('a', {
                innerHTML: 'text',
                href: 'https://google.com'
            })
        ]);``` - creates an element with a child.
    • `const node = this.makeElement('page', {

            xmlns: 'http://www.w3.org/1999/xhtml',
            className: 'test-class another-test-class'
        });``` - creates an element with custom namespace.
  • matches(element, selector) - Element.matches() polyfill.

  • subscribe(eventName, listener, context) - subscribe to an event.

  • emit(eventName, ...arg) - emit on an event.

View

View class contains the following methods:

  • query(selectors) - returns an array of all elements descended from the selector.

  • addListener(type, match, method) - adds an event listener to specified listener.

  • remove() - removes the element.