Add event bubbling support for Infoboxes
Review Request #9306 — Created Oct. 22, 2017 and discarded
Currently the only mechanism to register Infoboxes is to pass in a list of elements to
InfoboxManagerView.addTargets. This creates event listeners on each individual element. This mechanism is okay when the number of elements is small, however becomes ineficient when needing to listen for events on a large number of elements.This change adds a new mechanism
addContainerSelectortoInfoboxManagerView. Instead of adding listeners to each element,addContainerSelectorregisters a single listener on the parent container which listens and triggers events for the children specified in the selector.
- Existing unit tests passed
- Two new unit tests passed
- Manual testing: created a dummy infobox type and added it to
DiffReviewableViewon all'.n'Pygments classes. Ensured events triggered when hovering over specified classes, but not when hovering over non-specified classes. This manual testing only covered themouseenterevents and not themouseleaveevents.
| Description | From | Last Updated |
|---|---|---|
|
Typo in your description: "inneficient" -> "inefficient". |
|
|
|
Another typo in your description: addContaineSelector -> addContainerSelector. |
|
|
|
One last description typo: "specefied" -> "specified" |
|
|
|
Nit: that's a lot of the use of the word "specified". How about: "Hovering over one of the children in … |
|
|
|
Does it have to be a jQuery element? I see on line 108 you're passing it to $. Doesn't that … |
|
|
|
Nit: "showed" -> "shown" |
|
|
|
Nit: space after // |
|
|
|
Col: 36 ['args'] is better written in dot notation. |
|
|
|
Nit: space after // |
|
|
|
Nit: space after // |
|
|
|
Col: 36 ['args'] is better written in dot notation. |
|
|
|
Nit: space after // |
|
|
|
Col: 36 ['args'] is better written in dot notation. |
|
-
This looks really good, @slamo - just a few minor things I found; all cosmetic.
-
-
-
-
Nit: that's a lot of the use of the word "specified". How about:
"Hovering over one of the children in the container will trigger the specified infobox." ?
I think that conveys the same meaning.
-
Does it have to be a jQuery element? I see on line 108 you're passing it to $. Doesn't that mean it could be a raw DOM node?
-
-
-
-
-
- Description:
-
~ Currently the only mechanism to register Infoboxes is to pass in a list of elements to
InfoboxManagerView.addTargets. This creates event listeners on each individual element. This mechanism is okay when the number of elements is small, however becomes inneficient when needing to listen for events on a large number of elements.~ Currently the only mechanism to register Infoboxes is to pass in a list of elements to
InfoboxManagerView.addTargets. This creates event listeners on each individual element. This mechanism is okay when the number of elements is small, however becomes ineficient when needing to listen for events on a large number of elements.~ This change adds a new mechanism
addContainerSelectortoInfoboxManagerView. Instead of adding listeners to each element,addContaineSelectorregisters a single listener on the parent container which listens and triggers events for the children specefied in the selector.~ This change adds a new mechanism
addContainerSelectortoInfoboxManagerView. Instead of adding listeners to each element,addContainerSelectorregisters a single listener on the parent container which listens and triggers events for the children specified in the selector.
- Commit:
-
aed2e2dce131d32d3a4dd9dd5bcbddb5539fdc73350229aac9567673dab940a3ef25dbeb35f284eb
Checks run (2 succeeded)
-
-
I was originally trying to do this using
expect(infoboxManagerView._onTargetMouseEnter).toHaveBeenCalledWith($fooElement, DummyInfoboxView)however the$targetin the code had a context, whereas$fooElementdid not. This was my work-around for ensuring that the span being passed was the correct one. If there is a nicer way, or a way for me to have the span with a context in the test code, please let me know.