Skip to content

Commit

Permalink
Fix HTML sanitization bug and remove unnecessary async keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
BumpyClock committed Jan 12, 2024
1 parent 038ad8c commit 0daf136
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/scripts/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function createElement(tag, properties = {}, textContent = '') {

function sanitizeHTML(html) {
const tempElement = document.createElement('div');
tempElement.innerHTML = html;
tempElement.textContent = html;
return tempElement.textContent;
}

Expand All @@ -23,7 +23,7 @@ function createImageContainer(thumbnailUrl, siteTitle) {
return { imageContainer, cardbg };
}

async function createCard(item) {
function createCard(item) {
const docFrag = document.createDocumentFragment();
const card = createElement('div', { className: 'card' });

Expand Down Expand Up @@ -98,10 +98,10 @@ function reapplyEventHandlersToCachedCards() {
console.log("reapplying event handlers to cached cards");
const feedContainer = document.getElementById("feed-container");
const cards = feedContainer.querySelectorAll(".card");
const eventHandlersRestored = Array.from(cards).map((card) => {
const eventHandlersRestored = Array.from(cards).filter((card) => {
const linkURL = card.querySelector("a").href; // Example: getting the URL from the card's read more link
applyCardEventHandlers(card, linkURL);
return 1;
return true;
}).length;
console.log(`Restored ${eventHandlersRestored} event handlers`);
}

0 comments on commit 0daf136

Please sign in to comment.