-
Notifications
You must be signed in to change notification settings - Fork 174
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
[#1641] add parent option to createTag #1647
Conversation
…option, as discussed in https://github.com/orgs/adobecom/discussions/1641 - make usage of it in most obvious cases
Hello, I'm the AEM Code Sync Bot and I will run some test suites that validate the page speed.
|
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1647 +/- ##
==========================================
- Coverage 95.67% 95.02% -0.65%
==========================================
Files 154 153 -1
Lines 39657 39562 -95
==========================================
- Hits 37940 37592 -348
- Misses 1717 1970 +253 ☔ View full report in Codecov by Sentry. |
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.
Looking good for the most part, it must've been a tedious task to go through all of these. I just have a few notes
Also, you could add the |
@@ -143,8 +143,7 @@ async function combineLibraries(base, supplied) { | |||
function createList(libraries) { | |||
const container = createTag('div', { class: 'con-container' }); | |||
|
|||
const libraryList = createTag('ul', { class: 'sk-library-list' }); | |||
container.append(libraryList); | |||
const libraryList = createTag('ul', { class: 'sk-library-list' }, null, { parent: container }); |
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.
you missed one element here -
const item = createTag('li', { class: 'content-type' }, type.replace('_', ' ')); |
@@ -22,6 +22,9 @@ export function createTag(tag, attributes, html) { | |||
el.setAttribute(key, val); | |||
}); | |||
} | |||
if (options?.parent) { |
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.
options will always be defined, no need for ?
. I think we can skip the whole if clause and do options.parent?.append(el);
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.
yes, forgot to cleanup that test, thanks
|
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.
Sorry for delay. I was out for most of December.
@@ -115,6 +115,5 @@ export default function init(el) { | |||
el.remove(); | |||
const obj = createVideoObject(metadata); | |||
if (!obj) return; | |||
const script = createTag('script', { type: 'application/ld+json' }, JSON.stringify(obj)); | |||
document.head.append(script); | |||
createTag('script', { type: 'application/ld+json' }, JSON.stringify(obj), { parent: document.head }); |
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.
lgtm
@@ -42,8 +42,7 @@ export async function appendScriptTag({ locationUrl, getMetadata, createTag, get | |||
? SEOTECH_API_URL_PROD : SEOTECH_API_URL_STAGE; | |||
|
|||
const append = (obj) => { | |||
const script = createTag('script', { type: 'application/ld+json' }, JSON.stringify(obj)); | |||
document.head.append(script); | |||
createTag('script', { type: 'application/ld+json' }, JSON.stringify(obj), { parent: document.head }); |
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.
lgtm
@@ -572,6 +573,20 @@ describe('Utils', () => { | |||
}); | |||
}); | |||
|
|||
describe('createTag', async () => { |
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.
@npeltier did createTag
not have a UT prior to this diff?
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.
not specifically, but indirectly i think it was already 100% covered
@@ -84,7 +84,6 @@ function getEvent(el) { | |||
export default function init(el) { | |||
const event = getEvent(el); | |||
logNullValues(event); | |||
const script = createTag('script', { type: 'application/ld+json' }, JSON.stringify(event)); | |||
document.head.append(script); | |||
createTag('script', { type: 'application/ld+json' }, JSON.stringify(event), { parent: document.head }); |
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.
lgtm. not formal owner but it is seo.
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.
I would have opted to change these in batches and start with just changing the function first.
We always encourage small changes with small blast radiuses over large sweeping changes. The rare exception is net-new features that do not touch existing functionality (UAR, Merch, GlobalNav, etc.).
If one of these features blows up because there was a specific sequencing that should have been followed... appends have a very specific order, this entire PR must be reverted. Not having the complete historical knowledge of each use of create tag makes this a very risky PR.
Who is going to E2E QA this before it gets merged?
this makes sense, will make that PR the "feature" one, and usage in other ones (may be one per area, will see) |
actually will close that one for simplicity reasons :) |
core one #1698 |
Resolves: #1641
Test URLs:
Before: https://main--milo--adobecom.hlx.page/?martech=off
After: https://discussion_1641--milo--npeltier.hlx.page/?martech=off
Before: https://main--milo--adobecom.hlx.page/docs/library/kitchen-sink/merch-card?martech=off
After: https://discussion_1641--milo--npeltier.hlx.page/docs/library/kitchen-sink/merch-card?martech=off