KompElement (extends HTMLElement)
Base Element for all Komps Components. It provides some syntax sugar for working with Custom Elements, provides some built in events, and adds some helpful methods.
Syntax
class DropzoneElement extends KompsElement {}
window.customElements.define('komp-dropzone', DropzoneElement);
Options
types | description | |
---|---|---|
content
|
String, HTMLElement, Array, Object |
content to append to element. Passed to Dolla's |
Extending
static | types | description | arguments | |
---|---|---|---|---|
style
|
true | String |
Define style that is dynamically appended when component is used for the first time. |
|
defaults
|
true | Object |
keys and values to set on initialization |
|
connected
|
Function |
called when element is connected to a DOM element |
||
disconnected
|
Function |
called when element is disconnected from a DOM element |
||
remove
|
Function |
remove element, calls callback between event Triggers beforeRemove and afterRemove |
callback:Function | |
watch
|
true | Array |
array of attibutes to watch for changes and call |
Events
arguments | description | |
---|---|---|
beforeRemove
|
[] |
called before element is removed |
afterRemove
|
[] |
called after element is removed |
beforeConnect
|
[] |
called before element is connected |
afterConnect
|
[] |
called before element is connected |
beforeDisconnect
|
[] |
called before element is disconnected |
afterDisconnect
|
[] |
called before element is disconnected |
Methods
arguments | description | |
---|---|---|
intialize
|
[] |
method called once for each instantiation, but only after element is connected (required for accessing some properties) |
trigger
|
eventName:string, ...args |
triggers an event this element passes args |
addEventListenerFor
|
element:HTMLElement, eventType:string, ...args |
calls callback when eventType is triggered on element, enables component to tear down listener when disconnected. |
changed
|
attribute, was, now |
called every time an attribute of the element changes. Must include attribute in |
[attribute]Changed
|
was, now |
called every time |