Commit db3c26b
committed
bug #64475 [AssetMapper] Render an empty import map as a JSON object (ousamabenyounes)
This PR was merged into the 6.4 branch.
Discussion
----------
[AssetMapper] Render an empty import map as a JSON object
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix #64422
| License | MIT
When no entrypoint is passed (`{{ importmap([]) }}`) or the import map is
empty, `ImportMapRenderer` rendered the `imports` value as a JSON array:
```json
{
"imports": []
}
```
The import map specification requires `imports` to be a JSON **object**, so
browsers reject the empty array:
> Uncaught TypeError: Failed to parse import map: "imports" top-level key must be a JSON object.
An empty map is now serialized as a JSON object (`{}`); non-empty maps are
unchanged (an associative array already encodes as an object).
Commits
-------
33855da [AssetMapper] Render an empty import map as a JSON object2 files changed
+16-1Lines changed: 16 additions & 1 deletion
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- src/Symfony/Component/AssetMapper
- ImportMap
- Tests/ImportMap
Expand file treeCollapse file tree
Open diff view settings
Collapse file
src/Symfony/Component/AssetMapper/ImportMap/ImportMapRenderer.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/AssetMapper/ImportMap/ImportMapRenderer.php+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
96 | 96 | |
97 | 97 | |
98 | 98 | |
99 | | - |
| 99 | + |
100 | 100 | |
101 | 101 | |
102 | 102 | |
|
Collapse file
src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapRendererTest.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapRendererTest.php+15Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
204 | 204 | |
205 | 205 | |
206 | 206 | |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + |
| 214 | + |
| 215 | + |
| 216 | + |
| 217 | + |
| 218 | + |
| 219 | + |
| 220 | + |
| 221 | + |
207 | 222 | |
0 commit comments