Skip to content

Commit 52f3105

Browse files
committed
input-num disabled: extra work
I still prefer to set pointer-events to none for the <svg> and only set it to anything else for invisible event <rect>s.
1 parent 34f0f33 commit 52f3105

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

base-element.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export {VALUE, BaseElement};
1+
export {DISABLED, VALUE, BaseElement};
22
const
33
DISABLED = "disabled", // DOM attributes
44
TAB_INDEX = "tabindex",
@@ -79,7 +79,7 @@ class BaseElement extends HTMLElement {
7979
}
8080
// getters/setters reflect the HTML attributes, see attributeChangedCallback()
8181
get disabled() { return this.hasAttribute(DISABLED); }
82-
set disabled(val) { this._setBool(DISABLED, val); }
82+
set disabled(val) { this.toggleAttribute(DISABLED, val); }
8383

8484
// define wraps customElements.define for consistency of class and tag names
8585
static define(cls) {

input-num.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export {InputNum};
22

3-
import {VALUE, BaseElement} from "./base-element.js";
3+
import {DISABLED, VALUE, BaseElement} from "./base-element.js";
44
const
55
MAX = "max", // DOM attributes:
66
MIN = "min",
@@ -256,6 +256,9 @@ static observedAttributes = [
256256
case NOTATION: // convert null to undefined
257257
this.#locale[name] = val ?? undefined;
258258
break;
259+
case DISABLED: // falls through
260+
for (const elm of this.#btns)
261+
elm.style.pointerEvents = val ? "none" : "";
259262
default: // handled by BaseElement
260263
super.attributeChangedCallback(name, _, val);
261264
return;

0 commit comments

Comments
 (0)