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

30 lines
670 B
JavaScript
Raw Normal View History

/**
* Base class for component controllers.
*/
export default class Component {
/**
* The component owner window.
*/
get window() {
return this.document.defaultView;
}
/**
* The component owner document.
*/
get document() {
return this.element.ownerDocument;
}
/**
* Contructor.
*
* @param {HTMLElement} $element The main component element
* @param {$rootScope.Scope} $scope The element scope
*/
constructor($element, $scope) {
this.$ = $scope;
this.$element = $element;
this.element = $element[0];
}
}
Component.$inject = ['$element', '$scope'];