@@ -59,15 +59,17 @@ class BaseElement extends HTMLElement {
5959 this . #disabled = val ;
6060 }
6161 this . #disabling = true ;
62- if ( val !== null ) { // null == removeAttribute()
63- this . tabIndex = - 1 ; // indirectly recursive
64- this . #ptrEvents = this . style . pointerEvents ;
65- this . style . pointerEvents = "none" ;
66- }
67- else {
62+ if ( val === null ) // enabled: null == removeAttribute()
6863 this . tabIndex = this . #tabIndex;
69- this . style . pointerEvents = this . #ptrEvents;
64+ else {
65+ this . tabIndex = - 1 ; // disabled: indirectly recursive
66+ this . #ptrEvents = this . style . pointerEvents ;
7067 }
68+ const pe = getPointerEvents ( val , this . #ptrEvents) ;
69+ this . style . pointerEvents = pe ;
70+ if ( this . labels . length )
71+ for ( const lbl of this . labels )
72+ lbl . style . pointerEvents = pe ;
7173 return ;
7274 case TAB_INDEX :
7375 if ( this . #disabling) // easier done here, not case DISABLED
@@ -81,6 +83,8 @@ class BaseElement extends HTMLElement {
8183 get disabled ( ) { return this . hasAttribute ( DISABLED ) ; }
8284 set disabled ( val ) { this . toggleAttribute ( DISABLED , val ) ; }
8385
86+ get labels ( ) { return [ ...document . querySelectorAll ( `[for="${ this . id } "]` ) ] ; }
87+
8488// define wraps customElements.define for consistency of class and tag names
8589 static define ( cls ) {
8690 customElements . define ( classToTag ( cls ) , cls ) ;
@@ -151,6 +155,9 @@ function catchError(err) {
151155 console . error ( err . stack ?? err ) ;
152156}
153157//==============================================================================
158+ function getPointerEvents ( attrVal , val = "" ) {
159+ return ( attrVal === null ) ? val : "none" ;
160+ }
154161// classToTag() converts a class to a tag name
155162function classToTag ( cls ) {
156163 const name = cls . name ;
0 commit comments