]> git.proxmox.com Git - pve-manager.git/commitdiff
ext6migrate: fix framework caching issue
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 14 Mar 2016 12:41:23 +0000 (13:41 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 14 Mar 2016 16:16:58 +0000 (17:16 +0100)
in extjs 5/6 there is a caching issue, where they
save dom elements for reuse, but the garbage collector
can set them to null

when the framework now reuses the "cached" element it is null,
and any action on it produces an error, which breaks the site

for details see the forum link in the comment

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
www/manager6/Toolkit.js

index 263dea1652fabe4b40b2318935b663211d8a528a..ff59a55a08871d5e204c2e85af66ae61592eb61c 100644 (file)
@@ -112,6 +112,39 @@ Ext.override(Ext.form.field.ComboBox, {
     }
 });
 
+// ExtJs 5-6 has an issue with caching
+// see https://www.sencha.com/forum/showthread.php?308989
+Ext.define('PVE.UnderlayPool', {
+    override: 'Ext.dom.UnderlayPool',
+
+    checkOut: function () {
+        var cache = this.cache,
+            len = cache.length,
+            el;
+
+        // do cleanup because some of the objects might have been destroyed
+       while (len--) {
+            if (cache[len].destroyed) {
+                cache.splice(len, 1);
+            }
+        }
+        // end do cleanup
+
+       el = cache.shift();
+
+        if (!el) {
+            el = Ext.Element.create(this.elementConfig);
+            el.setVisibilityMode(2);
+            //<debug>
+            // tell the spec runner to ignore this element when checking if the dom is clean
+           el.dom.setAttribute('data-sticky', true);
+            //</debug>
+       }
+
+        return el;
+    }
+});
+
 Ext.define('Ext.ux.IFrame', {
     extend: 'Ext.Component',