css-inline-stream
Version:
Inline CSS classes into styles from HTML streams
13 lines • 476 B
JavaScript
// Helper function to parse existing inline style string into object
module.exports = function parseStyle(styleString) {
if (!styleString || !styleString.length) return {};
return styleString.split(';')
.filter(Boolean)
.reduce((acc, style) => {
const [property, value] = style.split(':').map(s => s.trim());
if (property && value) {
acc[property] = value;
}
return acc;
}, {});
}