bug #30973 [WebProfiler] Fix Javascript error when using custom stopwatch categories (curry684)

This PR was squashed before being merged into the 4.3-dev branch (closes #30973).

Discussion
----------

[WebProfiler] Fix Javascript error when using custom stopwatch categories

Fixes #30745

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30745
| License       | MIT

Made the getter do lazy creation so it can dynamically adapt to whatever it's given.

Commits
-------

e991472a76 [WebProfiler] Fix Javascript error when using custom stopwatch categories
This commit is contained in:
Fabien Potencier 2019-04-08 11:00:23 +02:00
commit 9b9d416cf6

View File

@ -252,11 +252,11 @@ class Legend {
}
get(category) {
return this.categories.find(element => element.value === category);
return this.categories.find(element => element.value === category) || this.createCategory(category);
}
getClassname(category) {
return this.classnames[category];
return this.classnames[category] || '';
}
getSectionClassname() {