Skip to content

Commit

Permalink
Merge pull request #774 from City-of-Helsinki/UHF-X_helfi_toc_heading…
Browse files Browse the repository at this point in the history
…_ids

UHF-X Helfi table of contents - heading ids
  • Loading branch information
khalima committed Jun 12, 2024
2 parents 5890294 + b988102 commit cc8dc03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions modules/helfi_toc/assets/js/tableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,6 @@
attach: function attach() {
const tableOfContents = document.getElementById('helfi-toc-table-of-contents');

// Bail if table of contents is not enabled.
if (!tableOfContents) {
return;
}

const tableOfContentsList = document.querySelector('#helfi-toc-table-of-contents-list > ul');
const mainContent = document.querySelector('main.layout-main-wrapper');
const reservedElems = document.querySelectorAll('[id]');
Expand All @@ -220,6 +215,12 @@

const { nodeName, anchorName} = Drupal.tableOfContents.createTableOfContentElements(content, []);

// Bail if table of contents is not enabled,
// but retain the heading element id.
if (!tableOfContents) {
return;
}

// Create table of contents if component is enabled.
if (tableOfContentsList && nodeName === 'h2') {
let listItem = document.createElement('li');
Expand Down
2 changes: 1 addition & 1 deletion modules/helfi_toc/helfi_toc.libraries.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
table_of_contents:
version: 1.0.2
version: 1.0.3
js:
assets/js/tableOfContents.js: {}
dependencies:
Expand Down

0 comments on commit cc8dc03

Please sign in to comment.