/**
 * @since Last modified: 2024/06/10 17:11:38
 * @function attrToJson
 * @description Convert the attribute text on the node to JSON.
 * @param {getEl} elem  - Target node or node selector, please refer to the util : getEl.
 * @param {string} attr  - Node attribute.
 * @returns {Object|{}} - Return a json.
 * @see {@link https://codepen.io/axui/pen/rNPmEqz|demo @ codepen}
 * @example
 * <div ax="a:0,b:1"></div>
 * attrToJson('#demo', 'ax');
 * <!--return {a:0,b:1}-->
 */
'use strict';
import getEl from './getEl';
import requireTypes from './requireTypes';
import strToJson from './strToJson';
const attrToJson = (elem, attr) => {
    requireTypes(attr, 'string');
    let el = getEl(elem), elAttr = el.getAttribute(attr), result = {};
    if (el && attr && elAttr) {
        result = strToJson(elAttr);
    }
    return result;
};
export default attrToJson;
