Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
chore(core): property initialization (backport)
Browse files Browse the repository at this point in the history
Fixes invalid native property initialization causing exception with
certain custom elements.
- closes #6589
- closes #6590

Signed-off-by: Cory Rylan <[email protected]>
  • Loading branch information
coryrylan committed Jan 25, 2022
1 parent 8f1fa37 commit ad5d1dc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/breadcrumb/breadcrumb.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export class CdsBreadcrumb extends LitElement {

@querySlot('[slot="cds-separator"]') private customSeparator: HTMLElement;

role = 'navigation';

render() {
return html`
<div class="private-host">
Expand All @@ -47,6 +45,11 @@ export class CdsBreadcrumb extends LitElement {
`;
}

connectedCallback() {
super.connectedCallback();
this.role = 'navigation';
}

private get separator() {
if (this.customSeparator) {
const separatorClone = this.customSeparator.cloneNode(true) as Element;
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/card/card.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ import styles from './card.element.scss';
* @cssprop --cds-card-remove-margin
*/
export class CdsCard extends CdsInternalPanel {
role = 'region';

@globalStyle() globalStyles = css`
[cds-card-remove-margin] {
margin-left: calc(-1 * var(--card-remove-margin));
Expand All @@ -61,4 +59,9 @@ export class CdsCard extends CdsInternalPanel {
static get styles() {
return [...super.styles, styles];
}

connectedCallback() {
super.connectedCallback();
this.role = 'region';
}
}
10 changes: 3 additions & 7 deletions packages/core/src/internal-components/overlay/overlay.element.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
Expand Down Expand Up @@ -92,12 +92,6 @@ export class CdsInternalOverlay extends CdsBaseFocusTrap implements Animatable {
@event()
cdsMotionChange: EventEmitter<string>;

@property({ type: String })
ariaModal = 'true';

@property({ type: String })
role = 'dialog';

// renderRoot needs delegatesFocus so that focus can cross the shadowDOM
// inside an element with aria-modal set to true
/** @private */
Expand Down Expand Up @@ -138,6 +132,8 @@ export class CdsInternalOverlay extends CdsBaseFocusTrap implements Animatable {

connectedCallback() {
super.connectedCallback();
this.ariaModal = 'true';
this.role = 'dialog';
window.addEventListener('keydown', this.fireEventOnEscape);
}

Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/navigation/navigation-item.element.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
Expand Down Expand Up @@ -71,10 +71,9 @@ export class CdsNavigationItem extends LitElement implements FocusableItem {
@querySlotAll('[cds-navigation-sr-text]')
itemText: NodeListOf<HTMLSpanElement>;

role = 'listitem';

connectedCallback() {
super.connectedCallback();
this.role = 'listitem';
if (!this.id) {
this.id = createId();
}
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/navigation/navigation-start.element.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
Expand Down Expand Up @@ -67,9 +67,6 @@ export class CdsNavigationStart extends LitElement implements FocusableItem {
@property({ type: Boolean, reflect: true })
isGroupStart = false;

@property({ type: String, reflect: true })
role = 'listitem';

@property({ type: String })
navigationGroupId: string;

Expand Down Expand Up @@ -107,6 +104,7 @@ export class CdsNavigationStart extends LitElement implements FocusableItem {

connectedCallback() {
super.connectedCallback();
this.role = 'listitem';
if (!this.id) {
this.id = createId();
}
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/navigation/navigation.element.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
Expand Down Expand Up @@ -174,8 +174,6 @@ export class CdsNavigation extends LitElement implements Animatable {
@querySlotAll('cds-navigation-group')
protected navigationGroupRefs: NodeListOf<CdsNavigationGroup>;

role = 'list';

private toggle() {
this.expandedChange.emit(!this.expanded);
}
Expand Down Expand Up @@ -365,6 +363,7 @@ export class CdsNavigation extends LitElement implements Animatable {

connectedCallback() {
super.connectedCallback();
this.role = 'list';
this.rootNavigationStart?.addEventListener('focus', this.focusRootStart.bind(this));
this.rootNavigationStart?.addEventListener('blur', this.blurRootStart.bind(this));
this.rootNavigationStart?.addEventListener('keydown', this.handleRootStartKeys.bind(this));
Expand Down

0 comments on commit ad5d1dc

Please sign in to comment.