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
addContainerSelector
toInfoboxManagerView
. Instead of adding listeners to each element,addContainerSelector
registers 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
DiffReviewableView
on 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 themouseenter
events and not themouseleave
events.
Description | From | Last Updated |
---|---|---|
Typo in your description: "inneficient" -> "inefficient". |
mike_conley | |
Another typo in your description: addContaineSelector -> addContainerSelector. |
mike_conley | |
One last description typo: "specefied" -> "specified" |
mike_conley | |
Nit: that's a lot of the use of the word "specified". How about: "Hovering over one of the children in … |
mike_conley | |
Does it have to be a jQuery element? I see on line 108 you're passing it to $. Doesn't that … |
mike_conley | |
Nit: "showed" -> "shown" |
mike_conley | |
Nit: space after // |
mike_conley | |
Col: 36 ['args'] is better written in dot notation. |
reviewbot | |
Nit: space after // |
mike_conley | |
Nit: space after // |
mike_conley | |
Col: 36 ['args'] is better written in dot notation. |
reviewbot | |
Nit: space after // |
mike_conley | |
Col: 36 ['args'] is better written in dot notation. |
reviewbot |
-
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
addContainerSelector
toInfoboxManagerView
. Instead of adding listeners to each element,addContaineSelector
registers 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
addContainerSelector
toInfoboxManagerView
. Instead of adding listeners to each element,addContainerSelector
registers 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$target
in the code had a context, whereas$fooElement
did 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.