Skip to content

Commit e5ef165

Browse files
committed
formAssociated and attachInternals()
1 parent 7792908 commit e5ef165

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

base-element.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ VALUE = "value"; // exported: defined here but not handled here
66
// =============================================================================
77
// The custom base class, direct sub-class of HTMLElement
88
class BaseElement extends HTMLElement {
9-
#connected; #disabled; #disabling; #id; #meta; #ptrEvents; #tabIndex;
9+
#connected; #disabled; #disabling; #id; #internals; #meta; #ptrEvents; #tabIndex;
1010
static searchParams; // set by html-elements.js, if it's used
1111
static observedAttributes = [DISABLED, TAB_INDEX];
12+
static formAssociated = true;
1213
static promises = new Map; // for noAwait, see https://github.com/sidewayss/html-elements/issues/8
1314
constructor(meta, template, noAwait) {
1415
super();
@@ -21,15 +22,17 @@ class BaseElement extends HTMLElement {
2122
this.#attach(template); // <template> as DocumentFragment
2223

2324
this.setAttribute(TAB_INDEX, "0"); // default value emulates <input>
25+
this.#internals = this.attachInternals(); // for accessibility, labels
2426
}
2527
#attach(template) {
2628
this._dom = this.attachShadow({mode:"open"});
2729
this._dom.appendChild(template.cloneNode(true));
2830
}
29-
// connectedCallback() exists for noAwait. It calls this._init(), which resides
30-
// in the bottom-level class. Classes with intermediate superclasses might call
31-
// this._initSuper(). If (!noAwait) it must call a pseudo-connectedCallback()
32-
// because a real one prevents this one from running.
31+
// connectedCallback() exists for DISABLED and noAwait. It calls this._init(),
32+
// which resides in the bottom-level class. Classes with intermediate super-
33+
// classes might call this._initSuper(). If (!noAwait) it must call a pseudo-
34+
// connectedCallback() called _connected(), because a real one prevents this
35+
// one from running.
3336
connectedCallback() {
3437
if (this.#meta) {
3538
getTemplate(this.#meta, this.#id).then(tmp => {

html-elements.xlsx

2.24 KB
Binary file not shown.

input-num.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ static observedAttributes = [
842842
return (inFocus ? n : this.#formatNumber(n))
843843
+ (appendUnits && this.units ? this.#getUnits() : "");
844844
}
845-
// #getUnits() gets the units text, currency && units displays currency per unit
845+
// #getUnits() gets the units text: currency && units displays currency per unit
846846
#getUnits() {
847847
return `${this.useLocale && this.#locale.currency ? "/" : ""}${this.units}`;
848848
}

0 commit comments

Comments
 (0)