Chromium Code Reviews| Index: ui/login/resource_loader.js |
| diff --git a/ui/login/resource_loader.js b/ui/login/resource_loader.js |
| index 56a68353cf9dbf8aefbcdcaf98813a207ca0817a..663d14384579640160d3ccf211078557168d2dbd 100644 |
| --- a/ui/login/resource_loader.js |
| +++ b/ui/login/resource_loader.js |
| @@ -216,9 +216,18 @@ cr.define('cr.ui.login.ResourceLoader', function() { |
| * @param {string} id Identifier of the element to wait for. |
|
jdufault
2016/06/23 19:51:15
Update docs.
sammiequon
2016/06/24 18:07:55
Done.
|
| * @param {function()} callback Function to invoke when done loading. |
| */ |
| - function waitUntilLayoutComplete(id, callback) { |
| + function waitUntilLayoutComplete(selector, callback) { |
| + var type = typeof selector; |
| + if (type != 'string' && type != 'function') |
|
jdufault
2016/06/23 19:51:15
Crashing is typically better than silently failing
sammiequon
2016/06/24 18:07:55
Done.
|
| + return; |
| + |
| var doWait = function() { |
| - var element = $(id); |
| + var element; |
| + if (type == 'string') |
|
jdufault
2016/06/23 19:51:15
Alternatively, you could make selector always be a
sammiequon
2016/06/24 18:07:55
Done.
|
| + element = $(selector); |
| + else |
| + element = selector(); |
| + |
| if (!element || !element.offsetHeight) { |
| requestAnimationFrame(doWait); |
| return; |