Skip to content

Commit

Permalink
adjust decorate and marquee anchors to hopefully pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sartxi authored and overmyheadandbody committed Nov 6, 2024
1 parent a8061bc commit 2cbb145
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/blocks/marquee-anchors/marquee-anchors.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function init(el) {
const emptyLinkRows = links.querySelectorAll(':scope > div:not([class])');
if (emptyLinkRows[0]) emptyLinkRows[0].classList.add('links-header');
if (emptyLinkRows[1]) emptyLinkRows[1].classList.add('links-footer', 'body-s');
decorateBlockText(emptyLinkRows[0], blockTypeSizes.default.xsmall);
if (emptyLinkRows[0]) decorateBlockText(emptyLinkRows[0], blockTypeSizes.default.xsmall);

const anchors = el.querySelectorAll('.anchor-link');
if (anchors.length) decorateAnchors(anchors);
Expand Down
5 changes: 2 additions & 3 deletions libs/utils/decorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ function elContainsText(el) {
}

export function decorateBlockText(el, config = ['m', 's', 'm'], type = null) {
if (!el) return;
let headings = el.querySelectorAll('h1, h2, h3, h4, h5, h6');
if (!el.classList.contains('default')) {
let headings = el?.querySelectorAll('h1, h2, h3, h4, h5, h6');
if (headings) {
if (type === 'hasDetailHeading' && headings.length > 1) headings = [...headings].splice(1);
headings.forEach((h) => h.classList.add(`heading-${config[0]}`));
Expand All @@ -86,7 +85,7 @@ export function decorateBlockText(el, config = ['m', 's', 'm'], type = null) {
}
}
const bodyStyle = `body-${config[1]}`;
const emptyEls = el.querySelectorAll(':is(p, ul, ol, div):not([class])');
const emptyEls = el?.querySelectorAll(':is(p, ul, ol, div):not([class])');
if (emptyEls.length) {
[...emptyEls].filter(elContainsText).forEach((e) => e.classList.add(bodyStyle));
} else if (!el.classList.length && elContainsText(el)) {
Expand Down

0 comments on commit 2cbb145

Please sign in to comment.