@@ -79,7 +79,7 @@ describe('base button', () => {
7979 } ) ;
8080
8181 it ( 'should remove aria-disabled if readonly' , async ( ) => {
82- element . readonly = true ;
82+ element . readOnly = true ;
8383 await elementIsStable ( element ) ;
8484 expect ( element . _internals . ariaDisabled ) . toBe ( null ) ;
8585 expect ( element . matches ( ':state(disabled)' ) ) . toBe ( false ) ;
@@ -117,7 +117,7 @@ describe('base button', () => {
117117 expect ( element . _internals . ariaExpanded ) . toBe ( 'true' ) ;
118118 expect ( element . matches ( ':state(expanded)' ) ) . toBe ( true ) ;
119119
120- element . readonly = true ;
120+ element . readOnly = true ;
121121 await elementIsStable ( element ) ;
122122 expect ( element . _internals . ariaExpanded ) . toBe ( null ) ;
123123 expect ( element . matches ( ':state(expanded)' ) ) . toBe ( false ) ;
@@ -149,7 +149,7 @@ describe('base button', () => {
149149 expect ( element . _internals . ariaPressed ) . toBe ( 'true' ) ;
150150 expect ( element . matches ( ':state(pressed)' ) ) . toBe ( true ) ;
151151
152- element . readonly = true ;
152+ element . readOnly = true ;
153153 await elementIsStable ( element ) ;
154154 expect ( element . _internals . ariaPressed ) . toBe ( null ) ;
155155 expect ( element . matches ( ':state(pressed)' ) ) . toBe ( false ) ;
@@ -172,31 +172,54 @@ describe('base button', () => {
172172 } ) ;
173173
174174 it ( 'should remove tabindex and role if readonly' , async ( ) => {
175- element . readonly = true ;
175+ element . readOnly = true ;
176176 await elementIsStable ( element ) ;
177177 expect ( element . tabIndex ) . toBe ( - 1 ) ;
178178 expect ( element . _internals . role ) . toBe ( 'none' ) ;
179179 expect ( element . getAttribute ( 'role' ) ) . toBe ( null ) ;
180180 } ) ;
181181
182+ it ( 'should map readonly attribute to readOnly property' , async ( ) => {
183+ element . setAttribute ( 'readonly' , '' ) ;
184+ await elementIsStable ( element ) ;
185+ expect ( element . readOnly ) . toBe ( true ) ;
186+ } ) ;
187+
188+ it ( 'should reflect readOnly property to readonly attribute' , async ( ) => {
189+ element . readOnly = true ;
190+ await elementIsStable ( element ) ;
191+ expect ( element . hasAttribute ( 'readonly' ) ) . toBe ( true ) ;
192+
193+ element . readOnly = false ;
194+ await elementIsStable ( element ) ;
195+ expect ( element . hasAttribute ( 'readonly' ) ) . toBe ( false ) ;
196+ } ) ;
197+
198+ it ( 'should support deprecated readonly property alias' , async ( ) => {
199+ element . readonly = true ;
200+ await elementIsStable ( element ) ;
201+ expect ( element . readOnly ) . toBe ( true ) ;
202+ expect ( element . hasAttribute ( 'readonly' ) ) . toBe ( true ) ;
203+ } ) ;
204+
182205 it ( 'should set the button type to submit if not defined within a form element' , async ( ) => {
183206 await elementIsStable ( element ) ;
184207 expect ( element . type ) . toBe ( undefined ) ;
185208 expect ( buttonInForm . type ) . toBe ( 'button' ) ;
186209 expect ( submitButtonInForm . type ) . toBe ( 'submit' ) ;
187210 } ) ;
188211
189- it ( 'should add or remove button event listeners when readonly updates' , async ( ) => {
212+ it ( 'should add or remove button event listeners when readOnly updates' , async ( ) => {
190213 await elementIsStable ( submitButtonInForm ) ;
191- expect ( submitButtonInForm . readonly ) . toBe ( undefined ) ;
214+ expect ( submitButtonInForm . readOnly ) . toBe ( false ) ;
192215
193216 vi . spyOn ( submitButtonInForm , 'removeEventListener' ) ;
194- submitButtonInForm . readonly = true ;
217+ submitButtonInForm . readOnly = true ;
195218 await elementIsStable ( submitButtonInForm ) ;
196219 expect ( submitButtonInForm . removeEventListener ) . toBeCalledTimes ( 3 ) ; // 2x button controller, 1x command controller
197220
198221 vi . spyOn ( submitButtonInForm , 'addEventListener' ) ;
199- submitButtonInForm . readonly = false ;
222+ submitButtonInForm . readOnly = false ;
200223 await elementIsStable ( submitButtonInForm ) ;
201224 expect ( submitButtonInForm . addEventListener ) . toBeCalledTimes ( 3 ) ; // 2x button controller, 1x command controller
202225 } ) ;
0 commit comments