fix: Allow reregistering fields. by gonfunko · Pull Request #9290 · RaspberryPiFoundation/blockly
The basics
The details
Resolves
Fixes RaspberryPiFoundation/blockly-samples#2587
Proposed Changes
This PR updates field registration to not throw if a field is registered twice. This behavior is optional on the main registry, but is not exposed on the field registry. I considered making it optional here as well and propagating that value through, but I can't think of a reasonable case where, when you register a field, you want it to throw. I assume this was done to warn in case of accidental conflicts, but throwing seems aggressive for that vs a console.log(), and in the case of fields in particular where e.g. a field might be subclassed with the subclasses distributed as packages with no knowledge of each other, the registration code may not even be aware that it would need to allow re-registration.