-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: main
Are you sure you want to change the base?
Conversation
|
blocks/tree-view/tree-view.js
Outdated
@@ -109,6 +109,16 @@ const init = async (el) => { | |||
const topList = el.querySelector('ul'); | |||
|
|||
if (!topList) return; | |||
// TODO: Remove after fix from Helix5 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
blocks/tree-view/tree-view.js
Outdated
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, ''); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
<p>
generated in HTML from HelixResolves: MWPW-162868
Test URLs:
Before: https://main--da-bacom--adobecom.hlx.page/docs/library/blocks/tree-view?martech=off
After: https://mwpw-162868--da-bacom--adobecom.hlx.page/docs/library/blocks/tree-view?martech=off