src/js/helpers/ZxQuery.js
function ZxQuery(element) {
    /** @protected */
    this._selection = [];

    if (typeof element === 'undefined') {
        element = document.documentElement;
    }

    if (element instanceof ZxQuery) {
        return element;
    } else if (element instanceof HTMLCollection || element instanceof NodeList) {
        const list = this._selection = [];
        z$.each(element, function(i, el) {
            list.push(el);
        });
    } else if (Array.isArray(element)) {
        this._selection = element;
    } else if (element === window || element instanceof HTMLElement || element instanceof Node) {
        this._selection = [element];
    } else if (typeof element === 'string') {
        this._selection = document.documentElement.querySelectorAll(element);
    } else if (element !== null) { // if (typeof element === 'string') {
        _log.e('ZxQuery cannot wrap object of this type.', (typeof element), element);
        throw new Error('ZxQuery cannot wrap object of this type.');
    }
    return this;
}
function ZxQuery(element) {
    /** @protected */
    this._selection = [];

    if (typeof element === 'undefined') {
        element = document.documentElement;
    }

    if (element instanceof ZxQuery) {
        return element;
    } else if (element instanceof HTMLCollection || element instanceof NodeList) {
        const list = this._selection = [];
        z$.each(element, function(i, el) {
            list.push(el);
        });
    } else if (Array.isArray(element)) {
        this._selection = element;
    } else if (element === window || element instanceof HTMLElement || element instanceof Node) {
        this._selection = [element];
    } else if (typeof element === 'string') {
        this._selection = document.documentElement.querySelectorAll(element);
    } else if (element !== null) { // if (typeof element === 'string') {
        _log.e('ZxQuery cannot wrap object of this type.', (typeof element), element);
        throw new Error('ZxQuery cannot wrap object of this type.');
    }
    return this;
}
function ZxQuery ( element ) { /** @protected */ this . _selection = [ ] ; if ( typeof element === 'undefined' ) { element = document . documentElement ; } if ( element instanceof ZxQuery ) { return element ; } else if ( element instanceof HTMLCollection || element instanceof NodeList ) { const list = this . _selection = [ ] ; z$ . each ( element , function ( i , el ) { list . push ( el ) ; } ) ; } else if ( Array . isArray ( element ) ) { this . _selection = element ; } else if ( element === window || element instanceof HTMLElement || element instanceof Node ) { this . _selection = [ element ] ; } else if ( typeof element === 'string' ) { this . _selection = document . documentElement . querySelectorAll ( element ) ; } else if ( element !== null ) { // if (typeof element === 'string') { _log . e ( 'ZxQuery cannot wrap object of this type.' , ( typeof element ) , element ) ; throw new Error ( 'ZxQuery cannot wrap object of this type.' ) ; } return this ; }
ZxQuery, a very lite subset of jQuery-like functions
internally used in Zuix for DOM operations.

The constructor takes one optional argument that can be
a DOM element, a node list or a valid DOM query selector string expression.
If no parameter is given, the resulting ZxQuery object will wrap the
root *document* element.

@class ZxQuery
@param {Object|ZxQuery|Array<Node>|Node|NodeList|string|undefined} [element] Element or list of elements to include in the ZxQuery object.
@return {ZxQuery} The *ZxQuery* object containing the given element(s).
@constructor
ZxQuery a very lite subset of jQuery - like functions internally used in Zuix for DOM operations .