@@ -29,6 +29,7 @@ class TagRenderer implements ResetInterface
2929 private $ eventDispatcher ;
3030
3131 private $ renderedFiles = [];
32+ private $ renderedFilesWithAttributes = [];
3233
3334 public function __construct (
3435 EntrypointLookupCollectionInterface $ entrypointLookupCollection ,
@@ -48,7 +49,7 @@ public function __construct(
4849 $ this ->reset ();
4950 }
5051
51- public function renderWebpackScriptTags (string $ entryName , ?string $ packageName = null , ?string $ entrypointName = null , array $ extraAttributes = []): string
52+ public function renderWebpackScriptTags (string $ entryName , ?string $ packageName = null , ?string $ entrypointName = null , array $ extraAttributes = [], bool $ includeAttributes = false ): string
5253 {
5354 $ entrypointName = $ entrypointName ?: '_default ' ;
5455 $ scriptTags = [];
@@ -79,13 +80,14 @@ public function renderWebpackScriptTags(string $entryName, ?string $packageName
7980 $ this ->convertArrayToAttributes ($ attributes )
8081 );
8182
82- $ this ->renderedFiles ['scripts ' ][] = $ attributes ['src ' ];
83+ $ this ->renderedFiles ['scripts ' ][] = $ attributes ["src " ];
84+ $ this ->renderedFilesWithAttributes ['scripts ' ][] = $ attributes ;
8385 }
8486
8587 return implode ('' , $ scriptTags );
8688 }
8789
88- public function renderWebpackLinkTags (string $ entryName , ?string $ packageName = null , ?string $ entrypointName = null , array $ extraAttributes = []): string
90+ public function renderWebpackLinkTags (string $ entryName , ?string $ packageName = null , ?string $ entrypointName = null , array $ extraAttributes = [], bool $ includeAttributes = false ): string
8991 {
9092 $ entrypointName = $ entrypointName ?: '_default ' ;
9193 $ scriptTags = [];
@@ -117,7 +119,8 @@ public function renderWebpackLinkTags(string $entryName, ?string $packageName =
117119 $ this ->convertArrayToAttributes ($ attributes )
118120 );
119121
120- $ this ->renderedFiles ['styles ' ][] = $ attributes ['href ' ];
122+ $ this ->renderedFiles ['styles ' ][] = $ attributes ["href " ];
123+ $ this ->renderedFilesWithAttributes ['styles ' ][] = $ attributes ;
121124 }
122125
123126 return implode ('' , $ scriptTags );
@@ -133,14 +136,24 @@ public function getRenderedStyles(): array
133136 return $ this ->renderedFiles ['styles ' ];
134137 }
135138
139+ public function getRenderedScriptsWithAttributes (): array
140+ {
141+ return $ this ->renderedFilesWithAttributes ['scripts ' ];
142+ }
143+
144+ public function getRenderedStylesWithAttributes (): array
145+ {
146+ return $ this ->renderedFilesWithAttributes ['styles ' ];
147+ }
148+
136149 public function getDefaultAttributes (): array
137150 {
138151 return $ this ->defaultAttributes ;
139152 }
140153
141154 public function reset (): void
142155 {
143- $ this ->renderedFiles = [
156+ $ this ->renderedFiles = $ this -> renderedFilesWithAttributes = [
144157 'scripts ' => [],
145158 'styles ' => [],
146159 ];
0 commit comments