Skip to content

Commit 1043b03

Browse files
authored
Merge pull request #347 from adobe/unify-head-foot
chore: unify header/footer decoration
2 parents 72e2aa5 + 1449ba1 commit 1043b03

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

blocks/footer/footer.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import { loadFragment } from '../fragment/fragment.js';
66
* @param {Element} block The footer block element
77
*/
88
export default async function decorate(block) {
9+
// load footer as fragment
910
const footerMeta = getMetadata('footer');
10-
block.textContent = '';
11-
12-
// load footer fragment
1311
const footerPath = footerMeta ? new URL(footerMeta, window.location).pathname : '/footer';
1412
const fragment = await loadFragment(footerPath);
1513

1614
// decorate footer DOM
15+
block.textContent = '';
1716
const footer = document.createElement('div');
1817
while (fragment.firstElementChild) footer.append(fragment.firstElementChild);
1918

blocks/header/header.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function toggleMenu(nav, navSections, forceExpanded = null) {
8787
}
8888

8989
/**
90-
* decorates the header, mainly the nav
90+
* loads and decorates the header, mainly the nav
9191
* @param {Element} block The header block element
9292
*/
9393
export default async function decorate(block) {
@@ -97,6 +97,7 @@ export default async function decorate(block) {
9797
const fragment = await loadFragment(navPath);
9898

9999
// decorate nav DOM
100+
block.textContent = '';
100101
const nav = document.createElement('nav');
101102
nav.id = 'nav';
102103
while (fragment.firstElementChild) nav.append(fragment.firstElementChild);

0 commit comments

Comments
 (0)