MDL-77604 recentlyaccesseditems: convert HTMLCollection to an array.

While working on this issue MDL-76931(Upgrade core-js-bundle),
we need to convert a HTMLCollection like .children to an array to use forEach(),
so we can upgrade the core-js to the upper version.
This commit is contained in:
Meirza 2023-03-16 15:38:10 +07:00
parent 5e1df25566
commit a314425cd0
3 changed files with 4 additions and 4 deletions

View File

@ -5,6 +5,6 @@
* @copyright 2018 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("block_recentlyaccesseditems/main",["jquery","block_recentlyaccesseditems/repository","core/templates","core/notification"],(function($,Repository,Templates,Notification){var SELECTORS_CARDDECK_CONTAINER='[data-region="recentlyaccesseditems-view"]',SELECTORS_CARDDECK='[data-region="recentlyaccesseditems-view-content"]',SELECTORS_SHOWMORE_LINK='[data-region="recentlyaccesseditems-view"] [data-action="more-items"]';return{init:function(root){var limit,itemsContainer=(root=$(root)).find(SELECTORS_CARDDECK_CONTAINER),itemsContent=root.find(SELECTORS_CARDDECK);(limit=9,Repository.getRecentItems(limit)).then((function(items){var pageContentPromise=function(root,items){if(items.length>0){let hasmoreitems=!1;return items.length>3&&(hasmoreitems=!0),Templates.render("block_recentlyaccesseditems/view-cards",{items:items,hasmoreitems:hasmoreitems})}var noitemsimgurl=root.attr("data-noitemsimgurl");return Templates.render("block_recentlyaccesseditems/no-items",{noitemsimgurl:noitemsimgurl})}(itemsContainer,items);pageContentPromise.then((function(html,js){return Templates.replaceNodeContents(itemsContent,html,js),items.length>3&&(()=>{const showmoreLink=document.querySelector(SELECTORS_SHOWMORE_LINK);showmoreLink.addEventListener("click",(()=>{showmoreLink.classList.add("d-none"),document.querySelector('[data-region="items-list"]').children.forEach((function(hiddenItem){hiddenItem.style="display: block"}))}))})(),null})).catch(Notification.exception)})).catch(Notification.exception)}}}));
define("block_recentlyaccesseditems/main",["jquery","block_recentlyaccesseditems/repository","core/templates","core/notification"],(function($,Repository,Templates,Notification){var SELECTORS_CARDDECK_CONTAINER='[data-region="recentlyaccesseditems-view"]',SELECTORS_CARDDECK='[data-region="recentlyaccesseditems-view-content"]',SELECTORS_SHOWMORE_LINK='[data-region="recentlyaccesseditems-view"] [data-action="more-items"]';return{init:function(root){var limit,itemsContainer=(root=$(root)).find(SELECTORS_CARDDECK_CONTAINER),itemsContent=root.find(SELECTORS_CARDDECK);(limit=9,Repository.getRecentItems(limit)).then((function(items){var pageContentPromise=function(root,items){if(items.length>0){let hasmoreitems=!1;return items.length>3&&(hasmoreitems=!0),Templates.render("block_recentlyaccesseditems/view-cards",{items:items,hasmoreitems:hasmoreitems})}var noitemsimgurl=root.attr("data-noitemsimgurl");return Templates.render("block_recentlyaccesseditems/no-items",{noitemsimgurl:noitemsimgurl})}(itemsContainer,items);pageContentPromise.then((function(html,js){return Templates.replaceNodeContents(itemsContent,html,js),items.length>3&&(()=>{const showmoreLink=document.querySelector(SELECTORS_SHOWMORE_LINK);showmoreLink.addEventListener("click",(()=>{showmoreLink.classList.add("d-none");const hiddenItems=document.querySelector('[data-region="items-list"]').children;for(const hiddenItem of hiddenItems)hiddenItem.style="display: block"}))})(),null})).catch(Notification.exception)})).catch(Notification.exception)}}}));
//# sourceMappingURL=main.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -57,9 +57,9 @@ define(
showmoreLink.classList.add('d-none');
const hiddenItems = document.querySelector('[data-region="items-list"]').children;
hiddenItems.forEach(function(hiddenItem) {
for (const hiddenItem of hiddenItems) {
hiddenItem.style = "display: block";
});
}
});
};