Skip to content

Commit

Permalink
Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
rejas committed Feb 22, 2023
1 parent 62a796a commit 2d35d9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions js/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ const Loader = (function () {
* @param {string} fileName Path of the file we want to load.
* @returns {Promise} resolved when the file is loaded
*/
const loadFile = function (fileName) {
const loadFile = async function (fileName) {
const extension = fileName.slice((Math.max(0, fileName.lastIndexOf(".")) || Infinity) + 1);
let script, stylesheet;

switch (extension.toLowerCase()) {
case "js":
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
Log.log("Load script: " + fileName);
script = document.createElement("script");
script.type = "text/javascript";
Expand All @@ -211,7 +211,7 @@ const Loader = (function () {
document.getElementsByTagName("body")[0].appendChild(script);
});
case "css":
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
Log.log("Load stylesheet: " + fileName);

stylesheet = document.createElement("link");
Expand Down Expand Up @@ -247,7 +247,7 @@ const Loader = (function () {
* @param {Module} module The module that calls the loadFile function.
* @returns {Promise} resolved when the file is loaded
*/
loadFile: function (fileName, module) {
loadFileForModule: async function (fileName, module) {
if (loadedFiles.indexOf(fileName.toLowerCase()) !== -1) {
Log.log("File already loaded: " + fileName);
return Promise.resolve();
Expand Down
2 changes: 1 addition & 1 deletion js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const Module = Class.extend({
const loadNextDependency = async () => {
if (dependencies.length > 0) {
const nextDependency = dependencies[0];
await Loader.loadFile(nextDependency, this);
await Loader.loadFileForModule(nextDependency, this);
dependencies = dependencies.slice(1);
await loadNextDependency();
} else {
Expand Down

0 comments on commit 2d35d9e

Please sign in to comment.