{"version":3,"file":"getAttributesHTML.cjs","sources":["../../src/utils/getAttributesHTML.js"],"sourcesContent":["/**\n * Match a name that is legal for an HTML attribute. Excludes whitespace, quotes,\n * `>`, `/`, `=` and control characters, which would otherwise end the attribute\n * or the tag when the name is interpolated into markup. An empty name is excluded\n * as well, since it can't be serialized as a name.\n * @type {RegExp}\n * @private\n */\n// eslint-disable-next-line no-control-regex\nconst VALID_ATTRIBUTE_NAME = /^[^\\s\"'>/=\\u0000-\\u001F\\u007F-\\u009F]+$/;\n\n/**\n * Escape an attribute value. Values are serialized inside double quotes,\n * so escaping the double quote keeps the value from terminating the attribute.\n * @param {string} value Attribute value.\n * @return {string} Escaped attribute value.\n * @private\n */\nconst escapeAttributeValue = value => `${value}`.replace(/\"/g, '&quot;');\n\n/**\n * Generate HTML string from attributes object.\n * @param {Object} attributes Object containing attribute names and values.\n * @return {string} HTML string of attributes.\n * @module\n * @private\n */\nexport default function getAttributesHTML(attributes) {\n    const html = [];\n\n    Object.keys(attributes).forEach(key => {\n        let value = attributes[key];\n        // Skip invalid names, they can't be serialized as an attribute.\n        if (!VALID_ATTRIBUTE_NAME.test(key)) return;\n\n        if (value === true) {\n            html.push(key);\n        } else if (value !== false) {\n            if (value === null || typeof value === 'undefined') value = '';\n            html.push(`${key}=\"${escapeAttributeValue(value)}\"`);\n        }\n    });\n\n    return html.join(' ');\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,oBAAoB,GAAG,yCAAyC;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,oBAAoB,GAAG,KAAK,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAAS,iBAAiB,CAAC,UAAU,EAAE;AACtD,IAAI,MAAM,IAAI,GAAG,EAAE;;AAEnB,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI;AAC3C,QAAQ,IAAI,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC;AACnC;AACA,QAAQ,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;;AAE7C,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;AAC5B,YAAY,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC1B,QAAQ,CAAC,MAAM,IAAI,KAAK,KAAK,KAAK,EAAE;AACpC,YAAY,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE;AAC1E,YAAY,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,QAAQ;AACR,IAAI,CAAC,CAAC;;AAEN,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACzB;;;;"}