@@ -576,6 +576,10 @@ private function handleAttributeBinding(DOMElement $node): void
576
576
)
577
577
);
578
578
$ name = '__ATTRIBUTE_WITH_IF_CONDITION__ ' ;
579
+ $ oldValue = $ node ->getAttribute ($ name );
580
+ if ($ oldValue ) {
581
+ $ value = $ oldValue . ', ' . $ value ;
582
+ }
579
583
}
580
584
581
585
$ node ->setAttribute ($ name , $ value );
@@ -1312,20 +1316,21 @@ private function replaceScopedPlaceholders(string $html): string
1312
1316
*/
1313
1317
private function replaceAttributeWithIfConditionPlaceholders (string $ html ): string
1314
1318
{
1315
- $ pattern = '/__ATTRIBUTE_WITH_IF_CONDITION__="([-a-zA-Z0-9]+)\|([a-zA-Z0-9+= ]+)"/ ' ;
1319
+ $ pattern = '/__ATTRIBUTE_WITH_IF_CONDITION__="([^" ]+)"/ ' ;
1316
1320
if (preg_match_all ($ pattern , $ html , $ matches , PREG_SET_ORDER )) {
1317
1321
foreach ($ matches as $ match ) {
1318
- $ name = $ match [1 ];
1319
- $ value = $ this ->replacePlaceholders (base64_decode ($ match [2 ]));
1320
- $ condition = trim (str_replace (['{{ ' , '}} ' ], '' , $ value ));
1321
- if (in_array ($ name , ['checked ' , 'selected ' , 'disabled ' ])) {
1322
- $ value = $ name ;
1322
+ $ attributes = explode (', ' , $ match [1 ]);
1323
+ $ replaceHtml = '' ;
1324
+ foreach ($ attributes as $ attribute ) {
1325
+ [$ name , $ encodedValue ] = explode ('| ' , $ attribute );
1326
+ $ value = $ this ->replacePlaceholders (base64_decode ($ encodedValue ));
1327
+ $ condition = trim (str_replace (['{{ ' , '}} ' ], '' , $ value ));
1328
+ if (in_array ($ name , ['checked ' , 'selected ' , 'disabled ' ])) {
1329
+ $ value = $ name ;
1330
+ }
1331
+ $ replaceHtml .= ' {% if ' . $ condition . ' %} ' . $ name . '=" ' . $ value . '"{% endif %} ' ;
1323
1332
}
1324
- $ html = str_replace (
1325
- $ match [0 ],
1326
- '{% if ' . $ condition . ' %} ' . $ name . '=" ' . $ value . '"{% endif %} ' ,
1327
- $ html
1328
- );
1333
+ $ html = str_replace ($ match [0 ], trim ($ replaceHtml ), $ html );
1329
1334
}
1330
1335
}
1331
1336
0 commit comments