/**
 * @since Last modified: 2024-08-02 10:13:04
 * @function getEl
 * @description Get a HTMLElement node.Support to get a real node or virtual node
 * @param {string|HTMLElement} obj  - It can be node  or node selector such as#ID, .classname, NODENAME, [attribute]
 * @param {HTMLElement} parent  - Parent node, get sub-node from this node, default document.body
 * @returns {HTMLElement|null} Return a node or null
 * @see {@link https://codepen.io/axui/pen/JjxNQEO|demo @ codepen}
 * @example
 * ax.getEl('#demo');
 * <!--return a HTMLElement node-->
 */
'use strict';
import getDataType from './getDataType';
const getEl = (obj, wrap) => {
    let objType = getDataType(obj), parType = getDataType(wrap), parent = parType.includes('HTML') ? wrap : document.body.querySelector(wrap), result = null;
    if (obj) {
        if (objType.includes('HTML')) {
            result = obj;
        }
        else if (objType === 'String') {
            try {
                result = (parent || document.body).querySelector(obj.trim());
            }
            catch {
                result = null;
            }
        }
    }
    return result;
};
export default getEl;
