@@ -762,15 +762,15 @@ public function handleBinding(string $value, string $name, ?DOMElement $node = n
762
762
if (preg_match ('/^`(.*)`$/ ' , $ element , $ match )) {
763
763
$ dynamicValues [] = $ this ->handleTemplateStringBinding ($ match [1 ], $ twigOutput );
764
764
} elseif (preg_match ('/^\{(.*)\}$/ ' , $ element , $ match )) {
765
- $ this ->handleObjectBinding ([$ match [1 ]], $ dynamicValues , $ twigOutput );
765
+ $ this ->handleObjectBinding ([$ match [1 ]], $ dynamicValues , $ twigOutput, $ name === ' style ' );
766
766
} else {
767
767
$ dynamicValues [] = $ element ;
768
768
}
769
769
}
770
770
} elseif (preg_match ($ regexObjectBinding , $ value , $ matches )) {
771
771
$ this ->logger ->debug ('- object binding ' , ['value ' => $ value ]);
772
772
$ items = explode (', ' , $ matches ['elements ' ]);
773
- $ this ->handleObjectBinding ($ items , $ dynamicValues , $ twigOutput );
773
+ $ this ->handleObjectBinding ($ items , $ dynamicValues , $ twigOutput, $ name === ' style ' );
774
774
} elseif (preg_match ($ regexTemplateString , $ value , $ matches )) {
775
775
// <div :class="`abc ${someDynamicClass}`">
776
776
$ this ->logger ->debug ('- template string binding ' , ['value ' => $ value ]);
@@ -795,15 +795,15 @@ public function handleBinding(string $value, string $name, ?DOMElement $node = n
795
795
* @param string[] $dynamicValues
796
796
* @throws ReflectionException
797
797
*/
798
- protected function handleObjectBinding (array $ items , array &$ dynamicValues , bool $ twigOutput ): void
798
+ protected function handleObjectBinding (array $ items , array &$ dynamicValues , bool $ twigOutput, bool $ isStyle ): void
799
799
{
800
800
$ regexObjectElements = '/(?<isString>[" \']?)(?<class>[^" \']+)[" \']?\s*:\s*(?<condition>[^,]+)/x ' ;
801
801
foreach ($ items as $ item ) {
802
802
if (preg_match ($ regexObjectElements , $ item , $ matchElement )) {
803
803
$ dynamicValues [] = $ this ->builder ->prepareBindingOutput (
804
- $ matchElement ['isString ' ]
805
- ? $ this -> builder -> refactorCondition ( $ matchElement ['condition ' ]) . ' ? \'' . $ matchElement ['class ' ] . '\''
806
- : '\'' . $ matchElement ['class ' ] . ': \' + ' . $ matchElement ['condition ' ] ,
804
+ $ isStyle && ! $ matchElement ['isString ' ]
805
+ ? '\'' . $ matchElement ['class ' ] . ': \' + ' . $ matchElement ['condition ' ]
806
+ : $ this -> builder -> refactorCondition ( $ matchElement ['condition ' ]) . ' ? \'' . $ matchElement ['class ' ] . '\'' ,
807
807
$ twigOutput
808
808
);
809
809
}
0 commit comments