From ff2d6cbf0020264131fda0e461e54b25cb8ecbce Mon Sep 17 00:00:00 2001 From: timwlee Date: Thu, 12 Mar 2026 11:39:02 -0700 Subject: [PATCH] Resolve errors in console --- scripts/aem.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/aem.js b/scripts/aem.js index efff16a..399a14f 100644 --- a/scripts/aem.js +++ b/scripts/aem.js @@ -611,13 +611,19 @@ async function loadBlock(block) { return block; } +/** Block names that have corresponding /blocks/{name}/ modules. Prevents content divs from being treated as blocks. */ +const KNOWN_BLOCKS = new Set([ + 'accordion', 'cards', 'columns', 'footer', 'form', 'fragment', 'header', + 'hero', 'leftnav', 'notebox', 'table', 'tabs', 'video', +]); + /** * Decorates a block. * @param {Element} block The block element */ function decorateBlock(block) { const shortBlockName = block.classList[0]; - if (shortBlockName) { + if (shortBlockName && KNOWN_BLOCKS.has(shortBlockName)) { block.classList.add('block'); block.dataset.blockName = shortBlockName; block.dataset.blockStatus = 'initialized'; @@ -630,7 +636,8 @@ function decorateBlock(block) { } /** - * Decorates all blocks in a container element. + * Decorates all blocks in a container element. Only divs whose first class + * matches a known block name are treated as blocks. * @param {Element} main The container element */ function decorateBlocks(main) {