1- import { css , html , DelegateMixin , SlotMixin , DisabledWithTabIndexMixin } from '@lion/core' ;
2- import { LionLitElement } from '@lion/core/src/LionLitElement.js' ;
1+ import { css , html , SlotMixin , DisabledWithTabIndexMixin , LitElement } from '@lion/core' ;
32
4- export class LionButton extends DisabledWithTabIndexMixin (
5- DelegateMixin ( SlotMixin ( LionLitElement ) ) ,
6- ) {
3+ export class LionButton extends DisabledWithTabIndexMixin ( SlotMixin ( LitElement ) ) {
74 static get properties ( ) {
85 return {
96 role : {
@@ -14,6 +11,10 @@ export class LionButton extends DisabledWithTabIndexMixin(
1411 type : Boolean ,
1512 reflect : true ,
1613 } ,
14+ type : {
15+ type : String ,
16+ reflect : true ,
17+ } ,
1718 } ;
1819 }
1920
@@ -107,14 +108,6 @@ export class LionButton extends DisabledWithTabIndexMixin(
107108 ] ;
108109 }
109110
110- get delegations ( ) {
111- return {
112- ...super . delegations ,
113- target : ( ) => this . $$slot ( '_button' ) ,
114- attributes : [ 'type' ] ,
115- } ;
116- }
117-
118111 get slots ( ) {
119112 return {
120113 ...super . slots ,
@@ -129,9 +122,14 @@ export class LionButton extends DisabledWithTabIndexMixin(
129122 } ;
130123 }
131124
125+ get _nativeButtonNode ( ) {
126+ return this . querySelector ( '[slot=_button]' ) ;
127+ }
128+
132129 constructor ( ) {
133130 super ( ) ;
134131 this . role = 'button' ;
132+ this . type = 'submit' ;
135133 this . active = false ;
136134 this . __setupDelegationInConstructor ( ) ;
137135 }
@@ -146,12 +144,22 @@ export class LionButton extends DisabledWithTabIndexMixin(
146144 this . __teardownEvents ( ) ;
147145 }
148146
147+ updated ( changedProperties ) {
148+ super . updated ( changedProperties ) ;
149+ if ( changedProperties . has ( 'type' ) ) {
150+ const native = this . _nativeButtonNode ;
151+ if ( native ) {
152+ native . type = this . type ;
153+ }
154+ }
155+ }
156+
149157 _redispatchClickEvent ( oldEvent ) {
150158 // replacing `MouseEvent` with `oldEvent.constructor` breaks IE
151159 const newEvent = new MouseEvent ( oldEvent . type , oldEvent ) ;
152160 newEvent . __isRedispatchedOnNativeButton = true ;
153161 this . __enforceHostEventTarget ( newEvent ) ;
154- this . $$slot ( '_button' ) . dispatchEvent ( newEvent ) ;
162+ this . _nativeButtonNode . dispatchEvent ( newEvent ) ;
155163 }
156164
157165 /**
0 commit comments