1.1.18 • Published 6 years ago

@appstractdk/as-core v1.1.18

Weekly downloads
28
License
ISC
Repository
-
Last release
6 years ago

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.
    • 				className: 'test-class',
      			}, [
      				this.makeElement('a', {
      					innerHTML: 'text',
      					href: 'https://google.com'
      				})
      			]);``` - creates an element with a child.
    • 				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.