Commit 30325d4
committed
fix(c4): stop wrapping non-text named attributes that land in a text slot
A named attribute lands in a positional slot when the argument before it is
omitted, and the handlers for the text slots (`label`, `descr`, `techn`,
`type`) wrapped whatever arrived in `{ text: value }` regardless of which
field it was actually for. So
System(s, "S", $tags="cylinder")
stored `tags` as `{ text: 'cylinder' }`, while
System(s, "S", "desc", $tags="cylinder")
stored the string. Consumers read `$tags` as a string - `resolveNodeShape`
calls `.split(',')` on it - so the first form threw
`shape.tags.split is not a function` and the diagram failed to render.
Only a text field belongs in a `{ text }` wrapper, so the eleven slot
handlers now consult one set of field names and assign anything else raw,
matching what `assignAttributes` already did for the attributes that arrive
in their own slots.
Found while building `AddElementTag` support: the existing e2e case passes
only because its fixture supplies a description before `$tags`, so the
broken form was never exercised.
Regression tests cover both forms of `$tags`, a named `$descr` (which must
still be wrapped), `$sprite`/`$link`, and a relationship `$tags`; three of
the five fail without this change.1 parent 79252c6 commit 30325d4
3 files changed
Lines changed: 83 additions & 11 deletions
File tree
- .changeset
- packages/mermaid/src/diagrams/c4
- parser
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
| |||
114 | 121 | | |
115 | 122 | | |
116 | 123 | | |
117 | | - | |
| 124 | + | |
118 | 125 | | |
119 | 126 | | |
120 | 127 | | |
| |||
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
128 | | - | |
| 135 | + | |
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
| |||
171 | 178 | | |
172 | 179 | | |
173 | 180 | | |
174 | | - | |
| 181 | + | |
175 | 182 | | |
176 | 183 | | |
177 | 184 | | |
| |||
220 | 227 | | |
221 | 228 | | |
222 | 229 | | |
223 | | - | |
| 230 | + | |
224 | 231 | | |
225 | 232 | | |
226 | 233 | | |
| |||
231 | 238 | | |
232 | 239 | | |
233 | 240 | | |
234 | | - | |
| 241 | + | |
235 | 242 | | |
236 | 243 | | |
237 | 244 | | |
| |||
280 | 287 | | |
281 | 288 | | |
282 | 289 | | |
283 | | - | |
| 290 | + | |
284 | 291 | | |
285 | 292 | | |
286 | 293 | | |
| |||
291 | 298 | | |
292 | 299 | | |
293 | 300 | | |
294 | | - | |
| 301 | + | |
295 | 302 | | |
296 | 303 | | |
297 | 304 | | |
| |||
339 | 346 | | |
340 | 347 | | |
341 | 348 | | |
342 | | - | |
| 349 | + | |
343 | 350 | | |
344 | 351 | | |
345 | 352 | | |
| |||
390 | 397 | | |
391 | 398 | | |
392 | 399 | | |
393 | | - | |
| 400 | + | |
394 | 401 | | |
395 | 402 | | |
396 | 403 | | |
| |||
444 | 451 | | |
445 | 452 | | |
446 | 453 | | |
447 | | - | |
| 454 | + | |
448 | 455 | | |
449 | 456 | | |
450 | 457 | | |
| |||
455 | 462 | | |
456 | 463 | | |
457 | 464 | | |
458 | | - | |
| 465 | + | |
459 | 466 | | |
460 | 467 | | |
461 | 468 | | |
| |||
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
0 commit comments