From d095ed18f1977ed907ad4ac3195a71c5eb90f5bf Mon Sep 17 00:00:00 2001 From: Jack Lukic Date: Thu, 27 Oct 2016 22:38:06 -0400 Subject: [PATCH] #2534 - adds new DOM caching, which preserves events and final rendered state --- src/definitions/modules/tab.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/definitions/modules/tab.js b/src/definitions/modules/tab.js index ae958e057..8937a70b1 100644 --- a/src/definitions/modules/tab.js +++ b/src/definitions/modules/tab.js @@ -429,13 +429,21 @@ $.fn.tab = function(parameters) { ? evaluateScripts : settings.evaluateScripts ; - if(evaluateScripts) { - module.debug('Updating HTML and evaluating inline scripts', tabPath, html); - $tab.html(html); + if(typeof settings.cacheType == 'string' && settings.cacheType.toLowerCase() == 'dom' && typeof html !== 'string') { + $tab + .empty() + .append($(html).clone(true)) + ; } else { - module.debug('Updating HTML', tabPath, html); - tab.innerHTML = html; + if(evaluateScripts) { + module.debug('Updating HTML and evaluating inline scripts', tabPath, html); + $tab.html(html); + } + else { + module.debug('Updating HTML', tabPath, html); + tab.innerHTML = html; + } } } }, @@ -467,7 +475,17 @@ $.fn.tab = function(parameters) { } settings.onFirstLoad.call($tab[0], tabPath, parameterArray, historyEvent); settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent); - if(settings.cacheType != 'response') { + + if(typeof settings.cacheType == 'string' && settings.cacheType.toLowerCase() == 'dom' && $tab.children().length > 0) { + setTimeout(function() { + let + $clone = $tab.children().clone(true) + ; + $clone = $clone.not('script'); + module.cache.add(fullTabPath, $clone); + }, 0); + } + else { module.cache.add(fullTabPath, $tab.html()); } },