Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove obsolete getLocalName() #3110

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/elements/core/base-elements/action-base-element.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { html, LitElement, type TemplateResult } from 'lit';

import { hostAttributes } from '../decorators.js';
import { getLocalName } from '../dom.js';

/**
* Whenever an element can be disabled it has disabled property
Expand Down Expand Up @@ -64,10 +63,6 @@ export abstract class SbbActionBaseElement extends LitElement {

/** Default render method for button-like components. */
protected override render(): TemplateResult {
return html`
<span class="sbb-action-base ${this.localName ?? getLocalName(this)}">
${this.renderTemplate()}
</span>
`;
return html` <span class="sbb-action-base ${this.localName}">${this.renderTemplate()}</span> `;
}
}
3 changes: 1 addition & 2 deletions src/elements/core/base-elements/link-base-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { property } from 'lit/decorators.js';

import { SbbLanguageController } from '../controllers.js';
import { hostAttributes } from '../decorators.js';
import { getLocalName } from '../dom.js';
import { i18nTargetOpensInNewWindow } from '../i18n.js';

import { SbbActionBaseElement } from './action-base-element.js';
Expand Down Expand Up @@ -65,7 +64,7 @@ export abstract class SbbLinkBaseElement extends SbbActionBaseElement {
protected override render(): TemplateResult {
return html`
<a
class="sbb-action-base ${this.localName ?? getLocalName(this)}"
class="sbb-action-base ${this.localName}"
href=${this.href || nothing}
?download=${this.download}
target=${this.target || nothing}
Expand Down
2 changes: 2 additions & 0 deletions src/elements/core/dom/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const localNameCache = new Map<unknown, string>();
* https://github.com/lit/lit/blob/main/packages/labs/ssr-dom-shim/src.ts (See CustomElementRegistryShim)
*
* Can be removed once https://github.com/lit/lit/pull/4553 is merged/released.
*
* @deprecated Will be removed with next major version
*/
export function getLocalName(element: LitElement): string {
if (localNameCache.has(element.constructor)) {
Expand Down
6 changes: 2 additions & 4 deletions src/elements/core/mixins/named-slot-list-mixin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { html, type LitElement, nothing, type TemplateResult } from 'lit';
import { state } from 'lit/decorators.js';

import { getLocalName } from '../dom.js';

import type { AbstractConstructor } from './constructor.js';
import { SbbHydrationMixin, type SbbHydrationMixinType } from './hydration-mixin.js';

Expand Down Expand Up @@ -130,7 +128,7 @@ export const SbbNamedSlotListMixin = <
if (listSlotNames.length >= 2) {
return html`
<ul
class=${attributes.class || (this.localName ?? getLocalName(this))}
class=${attributes.class || this.localName}
aria-label=${attributes.ariaLabel || nothing}
aria-labelledby=${attributes.ariaLabelledby || nothing}
>
Expand All @@ -146,7 +144,7 @@ export const SbbNamedSlotListMixin = <
`;
} else if (listSlotNames.length === 1) {
return html`<sbb-screen-reader-only>${attributes.ariaLabel}</sbb-screen-reader-only>
<span class=${attributes.class || (this.localName ?? getLocalName(this))}>
<span class=${attributes.class || this.localName}>
<span><slot name=${listSlotNames[0].name}></slot></span>
</span>
${this.renderHiddenSlot()} `;
Expand Down
Loading