@webmate-studio/builder 0.2.173 → 0.2.174
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/html-cleaner.js +11 -6
package/package.json
CHANGED
package/src/html-cleaner.js
CHANGED
|
@@ -81,18 +81,23 @@ function transformIslandsToDataAttributes(html, availableIslands = [], component
|
|
|
81
81
|
return kebabTag;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
// Parse attributes string into
|
|
84
|
+
// Parse attributes string into a data-island-props JSON attribute.
|
|
85
|
+
// This preserves camelCase prop names (HTML attributes are case-insensitive
|
|
86
|
+
// and get lowercased by the browser, breaking camelCase like bgGray → bggray).
|
|
85
87
|
function parseAttrs(attrsString) {
|
|
86
|
-
const
|
|
87
|
-
const attrPattern = /([a-
|
|
88
|
+
const props = {};
|
|
89
|
+
const attrPattern = /([a-zA-Z][a-zA-Z0-9]*)\s*=\s*(?:\{([^}]+)\}|"([^"]*)"|'([^']*)')/g;
|
|
88
90
|
let attrMatch;
|
|
89
91
|
while ((attrMatch = attrPattern.exec(attrsString)) !== null) {
|
|
90
92
|
const propName = attrMatch[1];
|
|
91
93
|
const propValue = attrMatch[2] || attrMatch[3] || attrMatch[4];
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
// For {expression} values, wrap in braces to signal runtime evaluation
|
|
95
|
+
props[propName] = attrMatch[2] ? `{${propValue}}` : propValue;
|
|
94
96
|
}
|
|
95
|
-
|
|
97
|
+
if (Object.keys(props).length === 0) return '';
|
|
98
|
+
// Encode as JSON in data-island-props (preserves camelCase)
|
|
99
|
+
const json = JSON.stringify(props).replace(/"/g, '"');
|
|
100
|
+
return ` data-island-props="${json}"`;
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
// 1. Self-closing: <ComponentName attrs... />
|