Skip to content

Commit

Permalink
prevent cascading component init failure
Browse files Browse the repository at this point in the history
If one init function throws, the others are still launched

fixes #513
  • Loading branch information
lovasoa committed Aug 1, 2024
1 parent 31165d4 commit 0d7106d
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions sqlpage/sqlpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,15 @@ function load_scripts() {
}
}

function add_init_function(f) {
function add_init_fn(f) {
document.addEventListener('DOMContentLoaded', f);
document.addEventListener('fragment-loaded', f);
if (document.readyState !== "loading") f();
if (document.readyState !== "loading") setTimeout(f, 0);
}

add_init_function(function init_components() {
sqlpage_table();
sqlpage_map();
sqlpage_card();
sqlpage_form();
load_scripts();
});

add_init_fn(sqlpage_table);
add_init_fn(sqlpage_map);
add_init_fn(sqlpage_card);
add_init_fn(sqlpage_form);
add_init_fn(load_scripts);

0 comments on commit 0d7106d

Please sign in to comment.