@salesforcedevs/docs-components 1.17.11-lwc-fix-alpha → 1.17.11-lwc-fix-alpha1

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.17.11-lwc-fix-alpha",
3
+ "version": "1.17.11-lwc-fix-alpha1",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -2,6 +2,7 @@ import ContentLayout from "doc/contentLayout";
2
2
 
3
3
  const TOC_HEADER_TAG = "doc-heading";
4
4
  const RNB_BY_TAB = "docs-tab";
5
+ const SPECIFICATION_TAG = "doc-specification-content";
5
6
  export const OBSERVER_ATTACH_WAIT_TIME = 500;
6
7
 
7
8
  export default class LwcContentLayout extends ContentLayout {
@@ -15,7 +16,7 @@ export default class LwcContentLayout extends ContentLayout {
15
16
 
16
17
  private setRNBByTab() {
17
18
  const tabPanelListItem = this.getTabPanelList();
18
- this.rnbByTab = tabPanelListItem?.id === RNB_BY_TAB ? true : false;
19
+ this.rnbByTab = tabPanelListItem?.id === RNB_BY_TAB;
19
20
  }
20
21
 
21
22
  get showTabBasedRNB() {
@@ -27,54 +28,25 @@ export default class LwcContentLayout extends ContentLayout {
27
28
  * Uses caching to avoid repeated DOM queries
28
29
  */
29
30
  private hasSpecificationContent(): boolean {
30
- // Return cached result if available
31
31
  if (this.hasSpecContentCache !== null) {
32
32
  return this.hasSpecContentCache;
33
33
  }
34
34
 
35
- // Check if the main slot contains doc-specification-content
36
35
  const mainSlot = this.getMainSlot();
37
36
  if (mainSlot) {
38
37
  const assignedElements = (mainSlot as any).assignedElements();
39
38
 
40
39
  for (const element of assignedElements) {
41
- // Check if the element itself is doc-specification-content
42
- if (element.tagName === "doc-specification-content") {
43
- this.hasSpecContentCache = true;
44
- return true;
45
- }
46
- // Check if it contains doc-specification-content
47
- const specContent = element.querySelector(
48
- "doc-specification-content"
49
- );
50
- if (specContent) {
51
- this.hasSpecContentCache = true;
52
- return true;
53
- }
54
- // Also check in shadow root if it exists
55
- if (element.shadowRoot) {
56
- const shadowSpecContent = element.shadowRoot.querySelector(
57
- "doc-specification-content"
58
- );
59
- if (shadowSpecContent) {
60
- this.hasSpecContentCache = true;
61
- return true;
62
- }
40
+ if (
41
+ element.tagName === SPECIFICATION_TAG ||
42
+ element.querySelector(SPECIFICATION_TAG) ||
43
+ element.shadowRoot?.querySelector(SPECIFICATION_TAG)
44
+ ) {
45
+ return (this.hasSpecContentCache = true);
63
46
  }
64
47
  }
65
48
  }
66
-
67
- // Fallback: check the entire document for doc-specification-content
68
- const allSpecContent = document.querySelectorAll(
69
- "doc-specification-content"
70
- );
71
- if (allSpecContent.length > 0) {
72
- this.hasSpecContentCache = true;
73
- return true;
74
- }
75
-
76
- this.hasSpecContentCache = false;
77
- return false;
49
+ return (this.hasSpecContentCache = false);
78
50
  }
79
51
 
80
52
  /**
@@ -120,17 +92,11 @@ export default class LwcContentLayout extends ContentLayout {
120
92
  onTabChanged = () => {
121
93
  this.updateRNB();
122
94
 
123
- // Check if there's a hash in the URL and we have specification content
124
95
  const { hash } = window.location;
125
-
126
96
  if (this.hasSpecificationContent() && hash) {
127
- // Reset the scroll flag to allow scrolling to the hash
128
97
  this.didScrollToSelectedHash = false;
129
98
 
130
- // Use requestAnimationFrame to ensure the DOM is ready
131
- requestAnimationFrame(() => {
132
- this.updateHeadingForRNB();
133
- });
99
+ requestAnimationFrame(() => this.updateHeadingForRNB());
134
100
  }
135
101
  };
136
102
 
@@ -276,16 +242,12 @@ export default class LwcContentLayout extends ContentLayout {
276
242
  }
277
243
  }
278
244
 
279
- /**
280
- * Override parent's onSlotChange to clear caches when slot content changes
281
- */
282
245
  onSlotChange(): void {
283
246
  this.clearAllCaches();
284
247
  super.onSlotChange();
285
248
  }
286
249
 
287
250
  updateHeadingForRNB(): void {
288
- // We only need to update URL in case of /docs and ignore if tabs are used anywhere else in DSC
289
251
  if (this.showTabBasedRNB) {
290
252
  this.updateURL();
291
253
  }