File tree Expand file tree Collapse file tree 6 files changed +45
-31
lines changed Expand file tree Collapse file tree 6 files changed +45
-31
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,6 @@ export class LionField extends FormControlMixin(
4949 type : String ,
5050 reflect : true ,
5151 } ,
52- type : {
53- type : String ,
54- reflect : true ,
55- } ,
5652 } ;
5753 }
5854
@@ -103,7 +99,6 @@ export class LionField extends FormControlMixin(
10399 super ( ) ;
104100 this . name = '' ;
105101 this . submitted = false ;
106- this . type = 'text' ;
107102 }
108103
109104 connectedCallback ( ) {
@@ -144,9 +139,6 @@ export class LionField extends FormControlMixin(
144139 if ( changedProps . has ( 'name' ) ) {
145140 this . inputElement . name = this . name ;
146141 }
147- if ( changedProps . has ( 'type' ) ) {
148- this . inputElement . type = this . type ;
149- }
150142 }
151143
152144 /**
Original file line number Diff line number Diff line change @@ -128,18 +128,6 @@ describe('<lion-field>', () => {
128128 expect ( el . inputElement . getAttribute ( 'name' ) ) . to . equal ( 'foo' ) ;
129129 } ) ;
130130
131- it ( 'has a type which is reflected to an attribute and is synced down to the native input' , async ( ) => {
132- const el = await fixture ( `<${ tagString } >${ inputSlotString } </${ tagString } >` ) ;
133- expect ( el . type ) . to . equal ( 'text' ) ;
134- expect ( el . getAttribute ( 'type' ) ) . to . equal ( 'text' ) ;
135- expect ( el . inputElement . getAttribute ( 'type' ) ) . to . equal ( 'text' ) ;
136-
137- el . type = 'foo' ;
138- await el . updateComplete ;
139- expect ( el . getAttribute ( 'type' ) ) . to . equal ( 'foo' ) ;
140- expect ( el . inputElement . getAttribute ( 'type' ) ) . to . equal ( 'foo' ) ;
141- } ) ;
142-
143131 // TODO: find out if we could put all listeners on this.value (instead of this.inputElement.value)
144132 // and make it act on this.value again
145133 it ( 'has a class "state-filled" if this.value is filled' , async ( ) => {
Original file line number Diff line number Diff line change @@ -21,14 +21,14 @@ export class LionInput extends LionField {
2121 type : Boolean ,
2222 attribute : 'readonly' ,
2323 } ,
24- } ;
25- }
26-
27- get delegations ( ) {
28- return {
29- ... super . delegations ,
30- properties : [ ... super . delegations . properties , 'step' ] ,
31- attributes : [ ... super . delegations . attributes , 'step' ] ,
24+ type : {
25+ type : String ,
26+ reflect : true ,
27+ } ,
28+ step : {
29+ type : Number ,
30+ reflect : true ,
31+ } ,
3232 } ;
3333 }
3434
@@ -47,6 +47,18 @@ export class LionInput extends LionField {
4747 } ;
4848 }
4949
50+ constructor ( ) {
51+ super ( ) ;
52+ this . readOnly = false ;
53+ this . type = 'text' ;
54+ /**
55+ * Only application to type="amount" & type="range"
56+ *
57+ * @deprecated
58+ */
59+ this . step = undefined ;
60+ }
61+
5062 _requestUpdate ( name , oldValue ) {
5163 super . _requestUpdate ( name , oldValue ) ;
5264 if ( name === 'readOnly' ) {
@@ -59,6 +71,16 @@ export class LionInput extends LionField {
5971 this . __delegateReadOnly ( ) ;
6072 }
6173
74+ updated ( changedProps ) {
75+ super . updated ( changedProps ) ;
76+ if ( changedProps . has ( 'type' ) ) {
77+ this . inputElement . type = this . type ;
78+ }
79+ if ( changedProps . has ( 'step' ) ) {
80+ this . inputElement . step = this . step ;
81+ }
82+ }
83+
6284 __delegateReadOnly ( ) {
6385 if ( this . inputElement ) {
6486 this . inputElement . readOnly = this . readOnly ;
Original file line number Diff line number Diff line change @@ -26,4 +26,16 @@ describe('<lion-input>', () => {
2626 const el = await fixture ( `<lion-input></lion-input>` ) ;
2727 expect ( el . querySelector ( 'input' ) ) . to . equal ( el . inputElement ) ;
2828 } ) ;
29+
30+ it ( 'has a type which is reflected to an attribute and is synced down to the native input' , async ( ) => {
31+ const el = await fixture ( `<lion-input></lion-input>` ) ;
32+ expect ( el . type ) . to . equal ( 'text' ) ;
33+ expect ( el . getAttribute ( 'type' ) ) . to . equal ( 'text' ) ;
34+ expect ( el . inputElement . getAttribute ( 'type' ) ) . to . equal ( 'text' ) ;
35+
36+ el . type = 'foo' ;
37+ await el . updateComplete ;
38+ expect ( el . getAttribute ( 'type' ) ) . to . equal ( 'foo' ) ;
39+ expect ( el . inputElement . getAttribute ( 'type' ) ) . to . equal ( 'foo' ) ;
40+ } ) ;
2941} ) ;
Original file line number Diff line number Diff line change 3333 ],
3434 "dependencies" : {
3535 "@lion/core" : " ^0.1.13" ,
36- "@lion/input " : " ^0.1.44 " ,
36+ "@lion/field " : " ^0.1.42 " ,
3737 "autosize" : " 4.0.2"
3838 },
3939 "devDependencies" : {
Original file line number Diff line number Diff line change 11import autosize from 'autosize/src/autosize.js' ;
2- import { LionInput } from '@lion/input ' ;
2+ import { LionField } from '@lion/field ' ;
33import { css } from '@lion/core' ;
44
55/**
@@ -8,7 +8,7 @@ import { css } from '@lion/core';
88 * @customElement
99 * @extends LionInput
1010 */
11- export class LionTextarea extends LionInput {
11+ export class LionTextarea extends LionField {
1212 static get properties ( ) {
1313 return {
1414 maxRows : {
You can’t perform that action at this time.
0 commit comments