Artur Arseniev
8 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
12 additions and
5 deletions
-
packages/core/src/parser/model/ParserHtml.ts
-
packages/core/test/specs/parser/model/ParserHtml.ts
|
|
|
@ -75,8 +75,9 @@ const ParserHtml = (em?: EditorModel, config: ParserConfig & { returnArray?: boo |
|
|
|
|
|
|
|
while (str.indexOf('/*') >= 0) { |
|
|
|
const start = str.indexOf('/*'); |
|
|
|
const end = str.indexOf('*/') + 2; |
|
|
|
str = str.replace(str.slice(start, end), ''); |
|
|
|
const end = str.indexOf('*/'); |
|
|
|
const endIndex = end > -1 ? end + 2 : undefined; |
|
|
|
str = str.replace(str.slice(start, endIndex), ''); |
|
|
|
} |
|
|
|
|
|
|
|
const decls = str.split(';'); |
|
|
|
|
|
|
|
@ -84,11 +84,17 @@ describe('ParserHtml', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
test('Parse style with comments', () => { |
|
|
|
expect(obj.parseStyle('/* color #ffffff; */ width: 100px;')).toEqual({ |
|
|
|
expect(obj.parseStyle('/* color #ffffff; */ width: 100px; /* height: 10px; */')).toEqual({ |
|
|
|
width: '100px', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Parse style with broken comments', () => { |
|
|
|
expect(obj.parseStyle('/* color #ffffff; */ height: 50px; /* width: 10px; ')).toEqual({ |
|
|
|
height: '50px', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Parse class string to array', () => { |
|
|
|
const str = 'test1 test2 test3 test-4'; |
|
|
|
const result = ['test1', 'test2', 'test3', 'test-4']; |
|
|
|
@ -922,8 +928,8 @@ describe('ParserHtml', () => { |
|
|
|
|
|
|
|
test('converts data-gjs-data-resolver to dataResolver', () => { |
|
|
|
const str = ` |
|
|
|
<div |
|
|
|
data-gjs-type="data-variable" |
|
|
|
<div |
|
|
|
data-gjs-type="data-variable" |
|
|
|
data-gjs-data-resolver='{"type":"data-variable","path":"some path","collectionId":"someCollectionId"}' |
|
|
|
></div> |
|
|
|
`;
|
|
|
|
|