Skip to content

Commit

Permalink
chore(chip): remove redundant property
Browse files Browse the repository at this point in the history
  • Loading branch information
mimshins committed Jan 6, 2025
1 parent 02c4169 commit e0a127a
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions packages/web-components/src/chip-group/chip-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,14 @@ export class ChipGroup extends LitElement {
@property({ type: Boolean, attribute: "full-width" })
public fullWidth = false;

/**
* The selected chips elements.
*/
public get selectedChips(): Chip[] {
if (isSSR()) return [];

return this._chips.filter(chip => chip.selected);
}

private get _chips() {
private get _selectedChips() {
const chipsSlot = getRenderRootSlot(this.renderRoot, Slots.DEFAULT);

if (!chipsSlot) return [];

const chips = chipsSlot
.assignedNodes()
.filter(node => node instanceof Chip);
.filter(node => node instanceof Chip && node.selected) as Chip[];

return chips;
}
Expand Down Expand Up @@ -97,7 +88,7 @@ export class ChipGroup extends LitElement {
const chip = event.target as Chip;
const value = chip.value;

const selectedValues = this.selectedChips
const selectedValues = this._selectedChips
.map(chip => chip.value)
.filter(v => v !== value);

Expand All @@ -112,7 +103,7 @@ export class ChipGroup extends LitElement {
const chip = event.target as Chip;
const value = chip.value;

const selectedValues = this.selectedChips
const selectedValues = this._selectedChips
.map(chip => chip.value)
.concat(value);

Expand Down

0 comments on commit e0a127a

Please sign in to comment.