/**
 * @since Last modified: 2024/02/29 17:30:06
 * @function tplToEl
 * @description Convert the node string to the DOM node, and you can use the appendchild method to insert the document.Support tr tags.
 * @param {string} tpl  - Node strings, only one root node is allowed.
 * @returns {HTMLElement|null} - Return a node.
 * @see {@link https://codepen.io/axui/pen/eYxxavg|demo @ codepen}
 * @example
 * ax.tplToEl('<ul><li>123</li></ul>');
 * <!--return ul node-->
 */
'use strict';
import createEl from './createEl';
import sliceStrEnd from './sliceStrEnd';
const tplToEl = (tpl) => {
    tpl = tpl.trim();
    if (!tpl) {
        return null;
    }
    let tplNode = createEl('TEMPLATE', '', tpl), clone = tplNode.content.cloneNode(true), elem = clone.firstElementChild;
    if (elem.nodeName === 'TR') {
        elem.innerHTML = sliceStrEnd({
            str: tplNode.innerHTML,
            key: '</tr>',
            contain: false,
        });
    }
    return elem;
};
export default tplToEl;
