Clean up and document event propagation properties #5880
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I had somehow missed #4510 and was a bit surprised to find out about this undocumented hack to get
FeatureGroup
to work.Thinking about it, I think the approach in itself is sane, but the real problem lies in the naming of the event property -
layer
is very specific toFeatureGroup
's utilization of the property.On the other hand, there's probably a lot of code out there that use this property, so I'm going for deprecating this property, although actually removing it is not something we need to do soon.
Instead, I added two properties:
sourceTarget
- this is the original target of the event, the object it was first fire on before any propagation occuredpropagatedFrom
- this is exactly the same as the currentlayer
; that is, the previous object in the chain of object propagating the event (to be honest, I don't feel 100% about the name of this property, so feel free to suggest a better one)Ideally, we should have made this analog to the DOM's
target
andcurrentTarget
, but we already use the propertytarget
with the same semantic as the DOM'scurrentTarget
, so that will unfortunately not work.