diff --git a/src/parser/model/ParserHtml.ts b/src/parser/model/ParserHtml.ts
index d83b32f22..b53bdff74 100644
--- a/src/parser/model/ParserHtml.ts
+++ b/src/parser/model/ParserHtml.ts
@@ -78,6 +78,13 @@ const ParserHtml = (em?: EditorModel, config: ParserConfig & { returnArray?: boo
*/
parseStyle(str: string) {
const result: Record = {};
+
+ while (str.indexOf('/*') >= 0) {
+ const start = str.indexOf('/*');
+ const end = str.indexOf('*/') + 2;
+ str = str.replace(str.slice(start, end), '');
+ }
+
const decls = str.split(';');
for (let i = 0, len = decls.length; i < len; i++) {
diff --git a/test/specs/parser/model/ParserHtml.ts b/test/specs/parser/model/ParserHtml.ts
index 2f1302c45..e4001e950 100644
--- a/test/specs/parser/model/ParserHtml.ts
+++ b/test/specs/parser/model/ParserHtml.ts
@@ -68,6 +68,12 @@ describe('ParserHtml', () => {
expect(obj.parseStyle(CSS_BG_STR)).toEqual(CSS_BG_OBJ);
});
+ test('Parse style with comments', () => {
+ expect(obj.parseStyle('/* color #ffffff; */ width: 100px;')).toEqual({
+ width: '100px',
+ });
+ });
+
test('Parse class string to array', () => {
var str = 'test1 test2 test3 test-4';
var result = ['test1', 'test2', 'test3', 'test-4'];