| 44 | pressed = false; |
| 45 | |
| 46 | _onclick(e: MouseEvent) { |
| 47 | e.stopImmediatePropagation(); |
| 48 | |
| 49 | if (this.nonInteractive) { |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | const { |
| 54 | altKey, |
| 55 | ctrlKey, |
| 56 | metaKey, |
| 57 | shiftKey, |
| 58 | } = e; |
| 59 | |
| 60 | const oldValue = this.pressed; |
| 61 | this.pressed = !oldValue; |
| 62 | |
| 63 | const prevented = !this.fireDecoratorEvent("click", { |
| 64 | originalEvent: e, |
| 65 | altKey, |
| 66 | ctrlKey, |
| 67 | metaKey, |
| 68 | shiftKey, |
| 69 | }); |
| 70 | |
| 71 | if (prevented) { |
| 72 | e.preventDefault(); |
| 73 | // value should be restored if click is prevented |
| 74 | this.pressed = oldValue; |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | if (isSafari()) { |
| 79 | this.getDomRef()!.focus(); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | ToggleButton.define(); |