all files / gluebert/src/element/ element.abstract.js

100% Statements 6/6
100% Branches 6/6
100% Functions 3/3
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46                                                                               
/**
 * Class represents ElementAbstract
 * @abstract
 */
class ElementAbstract {
 
    /**
     * Create an Element
     * @param {object} data
     * @param {DocumentFragment} template - shadow dom template reference
     */
    constructor(data, template) {
        this._data = (data)
            ? data
            : null;
 
        this._template = (template instanceof DocumentFragment)
            ? template
            : null;
    }
 
    /**
     * binds data to given shadow dom node
     */
    bindData() {
 
    }
 
    /**
     * creates node
     * @return {Node}
     */
    create() {
        if(!this._template) {
            return null;
        }
 
        this.bindData();
        return document.importNode(this._template, true);
    }
 
}
 
export {
    ElementAbstract,
};