@@ -60,10 +60,9 @@ public function execute(Observer $observer)
6060 return ;
6161 }
6262
63- $ html = preg_replace ('/^<([a-z]{2,})/ ' , '<\1 ' . $ htmlAttributes , $ html );
63+ $ html = preg_replace ('/^<([a-z]{2,})([^>]+)> / ' , '<\1 ' . $ htmlAttributes . ' > ' , $ html );
6464
6565 $ initialDataElement = $ this ->getInitialDataElement ($ component );
66-
6766 $ html = preg_replace ('/^<([^>]+)>/ ' , '<\1>[X-LOKI-INIT-BLOCK] ' , $ html );
6867 $ html = str_replace ('[X-LOKI-INIT-BLOCK] ' , $ initialDataElement , $ html );
6968
@@ -82,7 +81,7 @@ private function getHtmlAttributes(ComponentInterface $component, string $curren
8281 {
8382 $ block = $ component ->getBlock ();
8483
85- if (!preg_match ('/^<([^>]+)>/ ' , $ currentHtml , $ match )) {
84+ if (!preg_match ('/^<([a-z]{2,})([ ^>]+)>/ ' , $ currentHtml , $ match )) {
8685 return $ currentHtml ;
8786 }
8887
@@ -96,16 +95,19 @@ private function getHtmlAttributes(ComponentInterface $component, string $curren
9695 $ attributes ['x-title ' ] = $ this ->jsDataProvider ->getComponentId ($ component );
9796 }
9897
99- $ htmlAttribute = '' ;
98+ $ htmlAttributes = [] ;
10099 foreach ($ attributes as $ attributeName => $ attributeValue ) {
101100 if (str_contains ($ firstTagHtml , ' ' . $ attributeName . '=" ' )) {
102101 continue ;
103102 }
104103
105- $ htmlAttribute .= ' ' . $ attributeName . '=" ' . $ attributeValue . '" ' ;
104+ $ htmlAttributes [] = $ attributeName . '=" ' . $ attributeValue . '" ' ;
106105 }
107106
108- return trim ($ htmlAttribute );
107+ $ allAttributes = $ match [2 ] .' ' . implode (' ' , $ htmlAttributes );
108+ $ allAttributes = preg_replace ('/@([a-z.\-]+)=/ ' , ' x-on:\1= ' , $ allAttributes );
109+
110+ return $ allAttributes ;
109111 }
110112
111113 private function getJsData (ComponentInterface $ component ): string
0 commit comments