* Helper function to strip attribute prefix from attribute map * @param {object} attrs - Attributes with prefix (e.g., {"@_class": "code"}) * @param {string} prefix - Attribute prefix to remove (e.g., "@_") * @returns {object} Attributes without prefix (e.g., {"class": "code"})
(attrs, prefix)
| 12 | * @returns {object} Attributes without prefix (e.g., {"class": "code"}) |
| 13 | */ |
| 14 | function stripAttributePrefix(attrs, prefix) { |
| 15 | if (!attrs || typeof attrs !== 'object') return {}; |
| 16 | if (!prefix) return attrs; |
| 17 | |
| 18 | const rawAttrs = {}; |
| 19 | for (const key in attrs) { |
| 20 | if (key.startsWith(prefix)) { |
| 21 | const rawName = key.substring(prefix.length); |
| 22 | rawAttrs[rawName] = attrs[key]; |
| 23 | } else { |
| 24 | // Attribute without prefix (shouldn't normally happen, but be safe) |
| 25 | rawAttrs[key] = attrs[key]; |
| 26 | } |
| 27 | } |
| 28 | return rawAttrs; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * |