salix/client/core/src/lib/component.js

34 lines
804 B
JavaScript
Raw Normal View History

2018-10-18 07:24:20 +00:00
import EventEmitter from './event-emitter';
/**
* Base class for component controllers.
*/
2018-10-18 07:24:20 +00:00
export default class Component extends EventEmitter {
/**
* Contructor.
*
* @param {HTMLElement} $element The main component element
* @param {$rootScope.Scope} $scope The element scope
*/
constructor($element, $scope) {
2018-10-18 07:24:20 +00:00
super($element, $scope);
this.element = $element[0];
this.element.$ctrl = this;
this.$element = $element;
this.$ = $scope;
}
2018-10-18 07:24:20 +00:00
/**
* The component owner window.
*/
get window() {
return this.document.defaultView;
}
/**
* The component owner document.
*/
get document() {
return this.element.ownerDocument;
}
}
Component.$inject = ['$element', '$scope'];