fix for CPF when other scripts are also adding to sessionStorage (#8404)

This commit is contained in:
Matteo Piovanelli 2020-07-30 19:04:43 +02:00 committed by GitHub
parent c62203116f
commit 868ce12ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -5,7 +5,7 @@ namespace Orchard.ContentPicker {
public void BuildManifests(ResourceManifestBuilder builder) {
var manifest = builder.Add();
manifest.DefineScript("ContentPicker").SetUrl("ContentPicker.js", "ContentPicker.js").SetDependencies("jQuery");
manifest.DefineScript("SelectableContentTab").SetUrl("SelectableContentTab.js", "SelectableContentTab.js").SetDependencies("jQuery");
manifest.DefineScript("SelectableContentTab").SetUrl("SelectableContentTab.js?v=1.1", "SelectableContentTab.js?v=1.1").SetDependencies("jQuery");
}
}
}

View File

@ -32,8 +32,13 @@
$('.button.addSelected').on('click', function () {
var itemsToAdd = new Array();
for (var i = 0; i < sessionStorage.length; i++) {
var data = window.sessionStorage.getItem(sessionStorage.key(i));
itemsToAdd.push(JSON.parse(data));
var key = sessionStorage.key(i);
// only add the item if the key is an integer: other scripts may be
// adding stuff to sessionStorage
if (!isNaN(key - parseInt(key))) {
var data = window.sessionStorage.getItem(sessionStorage.key(i));
itemsToAdd.push(JSON.parse(data));
}
}
window.sessionStorage.clear();
window.opener.jQuery[query("callback")](itemsToAdd);