@@ -814,6 +814,7 @@ export class HTMLDocument extends Document {
814814 [ 'head' , HTMLHeadElement ] ,
815815 [ 'title' , HTMLTitleElement ] ,
816816 [ 'body' , HTMLBodyElement ] ,
817+ [ 'button' , HTMLButtonElement ] ,
817818 [ 'span' , HTMLSpanElement ] ,
818819 [ 'div' , HTMLDivElement ] ,
819820 ] ) ;
@@ -860,12 +861,21 @@ export class HTMLElement extends Element {
860861
861862 set inert ( value : boolean ) {
862863 if ( value ) {
863- this . setAttributeNS ( null , 'inert' , '' ) ;
864+ this . setAttributeNS ( null , 'inert' , String ( ) ) ;
864865 } else {
865866 this . removeAttributeNS ( null , 'inert' ) ;
866867 }
867868 }
868869
870+ get tabIndex ( ) : number {
871+ const attr = this . getAttributeNS ( null , 'tabindex' ) ;
872+ return attr === null ? - 1 : Number . parseInt ( attr , 10 ) || 0 ;
873+ }
874+
875+ set tabIndex ( value : number ) {
876+ this . setAttributeNS ( null , 'tabindex' , String ( value ) ) ;
877+ }
878+
869879 focus ( ) : void {
870880 if ( ! this . isConnected ) {
871881 return ;
@@ -924,12 +934,27 @@ export class HTMLSpanElement extends HTMLElement {}
924934
925935export class HTMLDivElement extends HTMLElement { }
926936
937+ export class HTMLButtonElement extends Focusable ( HTMLElement ) { }
938+
927939export class HTMLUnknownElement extends HTMLElement { }
928940
929941/** XML */
930942
931943export class XMLDocument extends Document { }
932944
945+ function Focusable < Ctor extends new ( ...args : any [ ] ) => HTMLElement > ( ElementType : Ctor ) : Ctor {
946+ return class FocusableElement extends ElementType {
947+ override get tabIndex ( ) : number {
948+ const attr = this . getAttributeNS ( null , 'tabindex' ) ;
949+ return attr ? super . tabIndex : 0 ;
950+ }
951+
952+ override set tabIndex ( value : number ) {
953+ super . tabIndex = value ;
954+ }
955+ } ;
956+ }
957+
933958export class FocusEvent extends Event {
934959 override readonly type : 'focus' | 'focusin' | 'focusout' | 'blur' ;
935960 readonly relatedTarget : Element | null ;
0 commit comments