Skip to content

Commit

Permalink
input-num disabled: extra work
Browse files Browse the repository at this point in the history
I still prefer to set pointer-events to none for the <svg> and only set it to anything else for invisible event <rect>s.
  • Loading branch information
sidewayss committed Dec 1, 2024
1 parent 34f0f33 commit 52f3105
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions base-element.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export {VALUE, BaseElement};
export {DISABLED, VALUE, BaseElement};
const
DISABLED = "disabled", // DOM attributes
TAB_INDEX = "tabindex",
Expand Down Expand Up @@ -79,7 +79,7 @@ class BaseElement extends HTMLElement {
}
// getters/setters reflect the HTML attributes, see attributeChangedCallback()
get disabled() { return this.hasAttribute(DISABLED); }
set disabled(val) { this._setBool(DISABLED, val); }
set disabled(val) { this.toggleAttribute(DISABLED, val); }

// define wraps customElements.define for consistency of class and tag names
static define(cls) {
Expand Down
5 changes: 4 additions & 1 deletion input-num.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export {InputNum};

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

0 comments on commit 52f3105

Please sign in to comment.