File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -4,16 +4,17 @@ import { StyleEngine } from '../styles/style-engine';
44import { Themable } from '../styles/themable' ;
55import { processDesignAttributes } from '../designs/design-attributes' ;
66
7- @inject ( ViewResources , StyleEngine )
7+ @inject ( Element , ViewResources , StyleEngine )
88@customElement ( 'ux-field' )
99@processAttributes ( processDesignAttributes )
1010
1111export class UxField implements Themable {
1212 @bindable public theme = null ;
13+ @bindable public label : string ;
1314
1415 public view : View ;
1516
16- constructor ( public resources : ViewResources , private styleEngine : StyleEngine ) { }
17+ constructor ( private element : Element , public resources : ViewResources , private styleEngine : StyleEngine ) { }
1718
1819 public created ( _ : any , myView : View ) {
1920 this . view = myView ;
@@ -23,6 +24,13 @@ export class UxField implements Themable {
2324 if ( this . theme ) {
2425 this . styleEngine . applyTheme ( this , this . theme ) ;
2526 }
27+
28+ if ( this . label && ! this . element . closest ( 'label' ) ) {
29+ const newLabel = document . createElement ( 'label' ) ;
30+ newLabel . textContent = this . label ;
31+
32+ this . element . insertBefore ( newLabel , this . element . firstChild ) ;
33+ }
2634 }
2735
2836 // public attached() { }
You can’t perform that action at this time.
0 commit comments