diff --git a/src/parser/model/ParserCss.js b/src/parser/model/ParserCss.js index f19d26ab5..9ddf2ad5b 100644 --- a/src/parser/model/ParserCss.js +++ b/src/parser/model/ParserCss.js @@ -72,12 +72,12 @@ module.exports = config => ({ // Create style object from the big one var stl = node.style; var style = {}; + for (var j = 0, len2 = stl.length; j < len2; j++) { - var propName = stl[j]; - //console.log('Style', stl, propName, ': ', stl.getPropertyValue(propName)); - var important = stl.getPropertyPriority(propName); - style[propName] = stl[propName] + - (important ? ' !' + important : ''); + const propName = stl[j]; + const propValue = stl.getPropertyValue(propName); + const important = stl.getPropertyPriority(propName); + style[propName] = `${propValue}${important ? ` !${important}` : ''}` } var lastRule = ''; diff --git a/test/specs/parser/model/ParserCss.js b/test/specs/parser/model/ParserCss.js index d31881762..426bc1926 100644 --- a/test/specs/parser/model/ParserCss.js +++ b/test/specs/parser/model/ParserCss.js @@ -199,6 +199,22 @@ module.exports = { expect(obj.parse(str)).toEqual(result) }); + it('Parse rule with CSS variables', () => { + var str = `:root { + --some-color: red; + --some-width: 55px; + }`; + var result = { + selectors: [], + selectorsAdd: ':root', + style: { + '--some-color': 'red', + '--some-width': '55px', + } + }; + expect(obj.parse(str)).toEqual(result) + }); + }); }