Skip to content

Commit

Permalink
Semantic-Org#2534 - adds new DOM caching, which preserves events and …
Browse files Browse the repository at this point in the history
…final rendered state
  • Loading branch information
jlukic committed Oct 28, 2016
1 parent a21cbce commit d095ed1
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/definitions/modules/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
},
Expand Down Expand Up @@ -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());
}
},
Expand Down

0 comments on commit d095ed1

Please sign in to comment.