All files / packages/sds-recipes/src/modules/c/buttonIcon buttonIcon.js

90.9% Statements 10/11
50% Branches 1/2
80% Functions 4/5
90.9% Lines 10/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44              97x 97x 97x 97x           50x 50x           166x 166x       97x                         5x    
import { LightningElement, api } from 'lwc';
import { reflectAttribute } from 'sds/utils';
 
export default class ButtonIcon extends LightningElement {
  // Render component in native shadow mode
  static shadowSupportMode = 'native';
 
  @api symbol;
  @api ariaLabel;
  @api disabled;
  @api selected;
 
  @api
  get variant() {
    return this._variant;
  }
  set variant(value) {
    this._variant = value;
    reflectAttribute(this, 'variant', this._variant);
  }
 
  @api
  get size() {
    return this._size;
  }
  set size(value) {
    this._size = value;
    reflectAttribute(this, 'size', this._size);
  I}
 
  connectedCallback() {
    // updates the selected attribute to pass aria-pressed value correctly to sds-button
    if (this.selected === '') {
      this.selected = 'true';
    }
    /* use below condition based on use case to handle selected button and aria-pressed behavior
       It handles aria-pressed and selected states for buttons which don't pass selected attribute
    */
    // if (!this.selected) {
    //   this.selected = 'false';
    // }
  }
}