File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ export class LionField extends FormControlMixin(
4949 type : String ,
5050 reflect : true ,
5151 } ,
52+ autocomplete : {
53+ type : String ,
54+ reflect : true ,
55+ } ,
5256 } ;
5357 }
5458
@@ -141,6 +145,10 @@ export class LionField extends FormControlMixin(
141145 if ( changedProps . has ( 'name' ) ) {
142146 this . inputElement . name = this . name ;
143147 }
148+
149+ if ( changedProps . has ( 'autocomplete' ) ) {
150+ this . inputElement . autocomplete = this . autocomplete ;
151+ }
144152 }
145153
146154 /**
Original file line number Diff line number Diff line change @@ -124,6 +124,17 @@ describe('<lion-field>', () => {
124124 expect ( el . $$slot ( 'input' ) . value ) . to . equal ( 'one' ) ;
125125 } ) ;
126126
127+ // This is necessary for security, so that inputElements autocomplete can be set to 'off'
128+ it ( 'delegates autocomplete property' , async ( ) => {
129+ const el = await fixture ( html `< ${ tag } > ${ inputSlot } </ ${ tag } > ` ) ;
130+ expect ( el . inputElement . autocomplete ) . to . equal ( '' ) ;
131+ expect ( el . inputElement . hasAttribute ( 'autocomplete' ) ) . to . be . false ;
132+ el . autocomplete = 'off' ;
133+ await el . updateComplete ;
134+ expect ( el . inputElement . autocomplete ) . to . equal ( 'off' ) ;
135+ expect ( el . inputElement . getAttribute ( 'autocomplete' ) ) . to . equal ( 'off' ) ;
136+ } ) ;
137+
127138 // TODO: find out if we could put all listeners on this.value (instead of this.inputElement.value)
128139 // and make it act on this.value again
129140 it ( 'has a class "state-filled" if this.value is filled' , async ( ) => {
You can’t perform that action at this time.
0 commit comments