diff --git a/javascript/clusterize.js b/javascript/clusterize.js index f222aea81..21f3d37ee 100644 --- a/javascript/clusterize.js +++ b/javascript/clusterize.js @@ -292,7 +292,8 @@ class Clusterize { // Get the first element that isn't one of our placeholder rows. const node = this.content_elem.querySelector(":scope > :not(.clusterize-extra-row,.clusterize-no-data)"); - if (!isElementLogError(node)) { + if (!isElement(node)) { + // dont attempt to compute dims if we have no data. return; } diff --git a/javascript/extraNetworksClusterize.js b/javascript/extraNetworksClusterize.js index 96feeee2e..0a5865d84 100644 --- a/javascript/extraNetworksClusterize.js +++ b/javascript/extraNetworksClusterize.js @@ -15,6 +15,9 @@ */ /*eslint no-undef: "error"*/ +// number of list html items to store in cache. +const EXTRA_NETWORKS_CLUSTERIZE_LRU_CACHE_SIZE = 1000; + class NotImplementedError extends Error { constructor(...params) { super(...params); @@ -72,7 +75,7 @@ class ExtraNetworksClusterize extends Clusterize { if (this.lru instanceof LRUCache) { this.lru.clear(); } else { - this.lru = new LRUCache(); + this.lru = new LRUCache(EXTRA_NETWORKS_CLUSTERIZE_LRU_CACHE_SIZE); } await this.reinitData(); diff --git a/javascript/utils.js b/javascript/utils.js index 7a649a81d..b0ff337f6 100644 --- a/javascript/utils.js +++ b/javascript/utils.js @@ -411,6 +411,11 @@ function htmlStringToElement(s) { return tmp.body.firstElementChild; } +function htmlStringToFragment(s) { + /** Converts an HTML string into a DocumentFragment. */ + return document.createRange().createContextualFragment(s); +} + function toggleCss(key, css, enable) { var style = document.getElementById(key); if (enable && !style) {