From 4e3934eb289e22001b28861703e768046ade9db6 Mon Sep 17 00:00:00 2001 From: Chris Haynes Date: Wed, 29 Jul 2020 12:15:47 +0100 Subject: [PATCH] Ensures there are no id clashes (#146) Ensures there are no id clashes by renaming the internal id property to componentId --- src/components/details/details.tsx | 10 +++++----- src/components/dialog/dialog.tsx | 6 +++--- src/components/drawer/drawer.tsx | 6 +++--- src/components/dropdown/dropdown.tsx | 6 +++--- src/components/tab-panel/tab-panel.tsx | 4 ++-- src/components/tab/tab.tsx | 4 ++-- src/components/tooltip/tooltip.tsx | 8 ++++---- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/components/details/details.tsx b/src/components/details/details.tsx index 4b0afa02..78ed98c6 100644 --- a/src/components/details/details.tsx +++ b/src/components/details/details.tsx @@ -24,7 +24,7 @@ let id = 0; export class Details { details: HTMLElement; header: HTMLElement; - id = `details-${++id}`; + componentId = `details-${++id}`; body: HTMLElement; /** Indicates whether or not the details is open. You can use this in lieu of the show/hide methods. */ @@ -156,11 +156,11 @@ export class Details { >
(this.header = el)} - id={`${this.id}-header`} + id={`${this.componentId}-header`} class="details__header" role="button" aria-expanded={this.open} - aria-controls={`${this.id}-content`} + aria-controls={`${this.componentId}-content`} aria-disabled={this.disabled} tabIndex={this.disabled ? -1 : 0} onClick={this.handleSummaryClick} @@ -178,10 +178,10 @@ export class Details {
(this.body = el)} class="details__body" onTransitionEnd={this.handleBodyTransitionEnd}>
diff --git a/src/components/dialog/dialog.tsx b/src/components/dialog/dialog.tsx index fbf36eb1..1aeedd82 100644 --- a/src/components/dialog/dialog.tsx +++ b/src/components/dialog/dialog.tsx @@ -29,7 +29,7 @@ let id = 0; export class Dialog { panel: HTMLElement; dialog: HTMLElement; - id = `dialog-${++id}`; + componentId = `dialog-${++id}`; @Element() host: HTMLSlDialogElement; @@ -196,12 +196,12 @@ export class Dialog { aria-modal="true" aria-hidden={!this.open} aria-label={this.noHeader ? this.label : null} - aria-labeledby={!this.noHeader ? `${this.id}-title` : null} + aria-labeledby={!this.noHeader ? `${this.componentId}-title` : null} tabIndex={0} > {!this.noHeader && (
- + {/* If there's no label, use an invisible character to prevent the heading from collapsing */} {this.label || String.fromCharCode(65279)} diff --git a/src/components/drawer/drawer.tsx b/src/components/drawer/drawer.tsx index 3065f874..df9f3a1b 100644 --- a/src/components/drawer/drawer.tsx +++ b/src/components/drawer/drawer.tsx @@ -28,7 +28,7 @@ let id = 0; export class Drawer { panel: HTMLElement; drawer: HTMLElement; - id = `drawer-${++id}`; + componentId = `drawer-${++id}`; @Element() host: HTMLSlDrawerElement; @@ -216,12 +216,12 @@ export class Drawer { aria-modal="true" aria-hidden={!this.open} aria-label={this.noHeader ? this.label : null} - aria-labeledby={!this.noHeader ? `${this.id}-title` : null} + aria-labeledby={!this.noHeader ? `${this.componentId}-title` : null} tabIndex={0} > {!this.noHeader && (
- + {/* If there's no label, use an invisible character to prevent the heading from collapsing */} {this.label || String.fromCharCode(65279)} diff --git a/src/components/dropdown/dropdown.tsx b/src/components/dropdown/dropdown.tsx index 2eddc8fe..202e878f 100644 --- a/src/components/dropdown/dropdown.tsx +++ b/src/components/dropdown/dropdown.tsx @@ -21,7 +21,7 @@ let id = 0; shadow: true }) export class Dropdown { - id = `dropdown-${++id}`; + componentId = `dropdown-${++id}`; ignoreMouseEvents = false; ignoreMouseTimeout: any; ignoreOpenWatcher = false; @@ -265,7 +265,7 @@ export class Dropdown { return (