@appstractdk/as-core

1.1.18 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @appstractdk/as-core

Weekly Downloads

9

Version

1.1.18

License

ISC

Unpacked Size

26.7 kB

Total Files

11

Last publish

Collaborators

  • appstract-team
  • raulstefan
  • ioanagrozav
  • mebappstract