This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1141362 - merge pull request #28769 from jrburke:bug1141362-email…
…-async-transitionend to mozilla-b2g:master
- Loading branch information
Showing
5 changed files
with
38 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
/** | ||
* transitionend is not guaranteed to be async after a layout recalulation. | ||
* Specifically, a clientHeight read might trigger sync dispatch of | ||
* transitionend event to listeners, which could end up calling the function | ||
* that did the clientHeight, but the first call would still be stuck waiting | ||
* on the clientHeight read to finish. The issue is tracked in bug 1135960. This | ||
* is a workaround for that, to guarantee async dispatch by using the async | ||
* nature of promise .then callbacks. | ||
*/ | ||
define(function(require, exports, module) { | ||
return function transitionEnd(node, fn, capturing) { | ||
function asyncFn(event) { | ||
Promise.resolve().then(function() { | ||
fn(event); | ||
}) | ||
.catch(function(error) { | ||
console.error(error); | ||
}); | ||
} | ||
node.addEventListener('transitionend', asyncFn, capturing); | ||
|
||
// Return the function used with addEventListener to allow the caller of | ||
// this helper to later call removeEventListener. | ||
return asyncFn; | ||
}; | ||
}); |