@salesforcedevs/docs-components 1.3.345-refactor-tab-alpha4 → 1.3.345-refactor-tab-alpha5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.3.345-refactor-tab-alpha4",
3
+ "version": "1.3.345-refactor-tab-alpha5",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -386,6 +386,22 @@ export default class ContentLayout extends LightningElement {
386
386
  this._tocOptions = tocOptions;
387
387
  }
388
388
 
389
+ setHashAndHeaderForDocHeading(headingElements: any) {
390
+ for (const headingElement of headingElements as any) {
391
+ // Sometimes elements hash and header is not being set when slot content is wrapped with div
392
+ if (!headingElement.hash) {
393
+ headingElement.hash = headingElement.attributes.hash?.nodeValue;
394
+ }
395
+
396
+ if (!headingElement.header) {
397
+ headingElement.header =
398
+ headingElement.attributes.header?.nodeValue;
399
+ }
400
+ }
401
+
402
+ this.updateTocItems(headingElements);
403
+ }
404
+
389
405
  onSlotChange(event: Event): void {
390
406
  const slotElements = (
391
407
  event.target as HTMLSlotElement
@@ -399,14 +415,7 @@ export default class ContentLayout extends LightningElement {
399
415
  TOC_HEADER_TAG
400
416
  );
401
417
 
402
- for (const headingElement of headingElements as any) {
403
- // Sometimes elements hash and header is not being set when slot content is wrapped with div
404
- headingElement.hash = headingElement.attributes.hash?.nodeValue;
405
- headingElement.header =
406
- headingElement.attributes.header?.nodeValue;
407
- }
408
-
409
- this.updateTocItems(headingElements);
418
+ this.setHashAndHeaderForDocHeading(headingElements);
410
419
  }
411
420
  }
412
421
 
@@ -35,22 +35,11 @@ export default class LwcContentLayout extends ContentLayout {
35
35
 
36
36
  updateRNB = () => {
37
37
  const headingElements = this.getHeadingElements();
38
- headingElements.forEach((headingElement: any) => {
39
- // Sometimes elements hash and header is not being set when slot content is wrapped with div
40
- if (!headingElement.hash) {
41
- headingElement.hash = headingElement.attributes.hash?.nodeValue;
42
- }
43
-
44
- if (!headingElement.header) {
45
- headingElement.header =
46
- headingElement.attributes.header?.nodeValue;
47
- }
48
- });
49
- this.updateTocItems(headingElements);
38
+ this.setHashAndHeaderForDocHeading(headingElements);
50
39
  };
51
40
 
52
41
  protected getHeadingElements() {
53
- let headingElements = document.querySelectorAll(TOC_HEADER_TAG);
42
+ let headingElements = super.getHeadingElements();
54
43
  if (this.showTabBasedRNB) {
55
44
  const tabPanelListItem: any = this.getTabPanelList();
56
45
  const tabPanels =
@@ -173,14 +162,11 @@ export default class LwcContentLayout extends ContentLayout {
173
162
  }
174
163
 
175
164
  updateHeadingForRNB(): void {
176
- // Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
177
- const headingElements = this.getHeadingElements();
178
-
179
165
  // We only need to update URL in case of /docs and ignore if tabs are used anywhere else in DSC
180
166
  if (this.showTabBasedRNB) {
181
167
  this.updateURL();
182
168
  }
183
- this.addObserverAndScroll(headingElements);
169
+ super.updateHeadingForRNB();
184
170
  }
185
171
 
186
172
  onSlotChange(): void {