From 342149a89d9420dfd8069a0931f6b388d4cc9e15 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 1 Dec 2018 19:06:28 +0100 Subject: [PATCH] Take care of parenthesis when split CSS style values. Fixes #1579 --- src/style_manager/model/PropertyComposite.js | 10 +++++++++- src/style_manager/view/PropertyCompositeView.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/style_manager/model/PropertyComposite.js b/src/style_manager/model/PropertyComposite.js index 9de929a1b..0c90649ee 100644 --- a/src/style_manager/model/PropertyComposite.js +++ b/src/style_manager/model/PropertyComposite.js @@ -43,7 +43,7 @@ module.exports = Property.extend({ * Update property values */ updateValues() { - const values = this.getFullValue().split(this.get('separator')); + const values = this.getFullValue().split(this.getSplitSeparator()); this.get('properties').each((property, i) => { const len = values.length; // Try to get value from a shorthand: @@ -56,6 +56,14 @@ module.exports = Property.extend({ }); }, + /** + * Split by sperator but avoid it inside parenthesis + * @return {RegExp} + */ + getSplitSeparator() { + return new RegExp(`${this.get('separator')}(?![^\\(]*\\))`); + }, + /** * Returns default value * @param {Boolean} defaultProps Force to get defaults from properties diff --git a/src/style_manager/view/PropertyCompositeView.js b/src/style_manager/view/PropertyCompositeView.js index a1192a505..9960be0af 100644 --- a/src/style_manager/view/PropertyCompositeView.js +++ b/src/style_manager/view/PropertyCompositeView.js @@ -111,7 +111,7 @@ module.exports = PropertyView.extend({ // the corresponding value from the requested index, otherwise try // to get the value of the sub-property if (targetValue) { - const values = targetValue.split(' '); + const values = targetValue.split(this.model.getSplitSeparator()); value = values[index]; } else { value =