Skip to content

Commit 92fb035

Browse files
committed
#7131 main.addon.HtmlStringToVdom: using Neo.createStyleObject()
1 parent dd6731c commit 92fb035

2 files changed

Lines changed: 2 additions & 19 deletions

File tree

src/main/addon/HtmlStringToVdom.mjs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class HtmlStringToVdom extends Base {
148148
if (attrName === 'class') {
149149
attrName = 'cls';
150150
} else if (attrName === 'style') {
151-
vdom.style = this.parseStyle(attrValue);
151+
vdom.style = Neo.createStyleObject(attrValue);
152152
continue;
153153
}
154154
vdom[attrName] = attrValue;
@@ -173,23 +173,6 @@ class HtmlStringToVdom extends Base {
173173

174174
return null; // Should not happen for valid HTML
175175
}
176-
177-
/**
178-
* Parses a style attribute string into an object.
179-
* @param {String} styleString The style string (e.g., "color: red; font-size: 16px").
180-
* @returns {Object} The style object.
181-
* @private
182-
*/
183-
parseStyle(styleString) {
184-
const style = {};
185-
styleString.split(';').forEach(declaration => {
186-
if (declaration.trim() !== '') {
187-
const [property, value] = declaration.split(':');
188-
style[property.trim()] = value.trim();
189-
}
190-
});
191-
return style;
192-
}
193176
}
194177

195178
export default Neo.setupClass(HtmlStringToVdom);

test/siesta/tests/functional/HtmlStringToVdom.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ StartTest(t => {
4343
cls: 'foo bar',
4444
style: {
4545
color: 'red',
46-
'font-size': '16px'
46+
fontSize: '16px'
4747
}
4848
});
4949
});

0 commit comments

Comments
 (0)