From 7d4be08dad9a2fb243431351f3bb29266d410c8a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 6 Mar 2020 17:25:37 +0100 Subject: [PATCH] Update the `FontLoader.bind` method to avoid explicitly returning `undefined` The only reason for the `return undefined;` lines was to appease the ESLint `consistent-return` rule, but that's not actually necessary if you make use of the fact that the method is `async` and that we can thus await the Promise rather than returning it. --- src/display/font_loader.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/display/font_loader.js b/src/display/font_loader.js index f2a568aca..c7cdd2625 100644 --- a/src/display/font_loader.js +++ b/src/display/font_loader.js @@ -71,7 +71,7 @@ class BaseFontLoader { async bind(font) { // Add the font to the DOM only once; skip if the font is already loaded. if (font.attached || font.missingFile) { - return undefined; + return; } font.attached = true; @@ -90,7 +90,7 @@ class BaseFontLoader { throw ex; } } - return undefined; // The font was, asynchronously, loaded. + return; // The font was, asynchronously, loaded. } // !this.isFontLoadingAPISupported @@ -99,14 +99,14 @@ class BaseFontLoader { this.insertRule(rule); if (this.isSyncFontLoadingSupported) { - return undefined; // The font was, synchronously, loaded. + return; // The font was, synchronously, loaded. } - return new Promise(resolve => { + await new Promise(resolve => { const request = this._queueLoadingCallback(resolve); this._prepareFontLoadEvent([rule], [font], request); }); + // The font was, asynchronously, loaded. } - return undefined; } _queueLoadingCallback(callback) {