Closed
Bug 1300339
Opened 8 years ago
Closed 8 years ago
Use addEventListener(..., {once: true}) in mail
Categories
(Thunderbird :: General, defect)
Thunderbird
General
Tracking
(thunderbird51 fixed)
RESOLVED
FIXED
Thunderbird 51.0
Tracking | Status | |
---|---|---|
thunderbird51 | --- | fixed |
People
(Reporter: aryx, Assigned: aryx)
Details
Attachments
(1 file)
(deleted),
patch
|
mkmelin
:
review+
|
Details | Diff | Splinter Review |
See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
Bug 1287706 added support for the 'once' option in addEventListener which works like an removeEventListener executed when the callback gets executed for the first time.
Advantage: add + remove in one statement, remove can't get lost
Try run: https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=27f431f97226
Yes, I made this patch to get used to this new feature.
Assignee | ||
Comment 1•8 years ago
|
||
Attachment #8787905 -
Flags: review?(mkmelin+mozilla)
Comment on attachment 8787905 [details] [diff] [review]
patch, v1
Review of attachment 8787905 [details] [diff] [review]:
-----------------------------------------------------------------
::: mail/base/content/glodaFacetView.js
@@ +588,4 @@
> // visible state actually happens.
> facetDate.getBoundingClientRect();
> }
> let listener = () => {
This looks weird to me :) I'm not sure what was saved by omitting 'function' here (not your fault).
::: mail/components/preferences/preferencesTab.js
@@ +86,5 @@
>
> if ("onLoad" in aArgs) {
> aTab.browser.addEventListener("paneload", function _contentTab_onLoad (event) {
> aArgs.onLoad(event, aTab.browser);
> + }, {capture: true, once: true});
Would it be more readable like this?
aTab.browser.addEventListener("paneload",
function _contentTab_onLoad (event) { aArgs.onLoad(event, aTab.browser); },
{capture: true, once: true});
::: mail/test/mozmill/shared-modules/test-window-helpers.js
@@ +677,3 @@
> focused = true;
> }
> + targetWindow.addEventListener("focus", onFocus, {capture: true, once: true});
Would this work as targetWindow.addEventListener("focus", function() { focused = true;}, {capture: true, once: true}); ?
Or is that too ugly? :)
Comment 3•8 years ago
|
||
Comment on attachment 8787905 [details] [diff] [review]
patch, v1
Review of attachment 8787905 [details] [diff] [review]:
-----------------------------------------------------------------
Looks ok to me, thx! r=mkmelin
(I'd fix aceman's second comment, maybe not the first.)
Attachment #8787905 -
Flags: review?(mkmelin+mozilla) → review+
Assignee | ||
Comment 4•8 years ago
|
||
(In reply to :aceman from comment #2)
> Comment on attachment 8787905 [details] [diff] [review]
> ::: mail/components/preferences/preferencesTab.js
> @@ +86,5 @@
> >
> > if ("onLoad" in aArgs) {
> > aTab.browser.addEventListener("paneload", function _contentTab_onLoad (event) {
> > aArgs.onLoad(event, aTab.browser);
> > + }, {capture: true, once: true});
>
> Would it be more readable like this?
> aTab.browser.addEventListener("paneload",
> function _contentTab_onLoad (event) { aArgs.onLoad(event, aTab.browser); },
> {capture: true, once: true});
Done.
> ::: mail/test/mozmill/shared-modules/test-window-helpers.js
> > + targetWindow.addEventListener("focus", onFocus, {capture: true, once: true});
>
> Would this work as targetWindow.addEventListener("focus", function() {
> focused = true;}, {capture: true, once: true}); ?
> Or is that too ugly? :)
Changed it to
> targetWindow.addEventListener("focus", () => focused = true, {capture: true, once: true});
https://hg.mozilla.org/comm-central/rev/c5b96634312c9f5dec485fdde01e1d77f1d2b33b
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-thunderbird51:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 51.0
You need to log in
before you can comment on or make changes to this bug.
Description
•