Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MWPW-162868]: Temp fix for extra <p> tag in <li> #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sharmeeatadobe
Copy link
Collaborator

@sharmeeatadobe sharmeeatadobe commented Jan 3, 2025

Copy link

aem-code-sync bot commented Jan 3, 2025

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

Copy link

aem-code-sync bot commented Jan 3, 2025

Page Scores Audits Google
📱 /docs/library/blocks/tree-view?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /docs/library/blocks/tree-view?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@@ -109,6 +109,16 @@ const init = async (el) => {
const topList = el.querySelector('ul');

if (!topList) return;
// TODO: Remove after fix from Helix5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the context on Helix 5 solving this? Looking at https://main--da-bacom--adobecom.aem.page/docs/library/blocks/tree-view?martech=off, using the Helix 5 domain, nothing changes, so it might be that Helix 5 will not solve this. Judging by this, the comment might not be relevant and the fix might need to be more permanent.

Copy link

@mokimo mokimo Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is misleading it's not fixed by helix-5 but a helix bug fix.

This will be fixed by adobe/helix-html2md#556 if this can make it into helix-html2md. However it's a breaking change on the helix side, so currently we don't have an ETA or clear path to getting this merged without being sure it doesn't affect other helix consumers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the comment now to mention bug fix along with the awaiting PR number.

const paragraph = liEl.querySelector('p');
if (paragraph) {
// Moving the content of the <p> into the <li> directly
liEl.innerHTML = paragraph.innerHTML + liEl.innerHTML.replace(paragraph.outerHTML, '');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using innerHTML will lead to security concerns. You might want to try some other strategies to prepend the content of the paragraph, or replace children, whatever makes the most sense to you, but without using innerHTML.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I do have another solution at hand as per the fixes made in milo blocks: https://github.com/adobecom/milo/pull/3412/files

Will implement that instead of innerHTML to avoid any risk of XSS

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed the new code change by using insertBefore() in the parent node. Please review again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants