@@ -50,42 +50,51 @@ class DeclaritiveBaseCustomWebcomponent extends BaseCustomWebComponentNoAttached
5050 }
5151 const name = this . name ;
5252 const definingElement = this ;
53- window [ name ] = function ( ) {
54- if ( window [ name ] . template === undefined )
55- window [ name ] . template = definingElement . querySelector ( 'template' ) ;
56- const instance = Reflect . construct ( BaseDeclaritiveWebcomponent , [ ] , window [ name ] ) ;
5753
58- for ( let p in props ) {
59- Object . defineProperty ( instance , p , {
60- get ( ) {
61- return this [ '_' + p ] ;
62- } ,
63- set ( newValue ) {
64- if ( this [ '_' + p ] !== newValue ) {
65- this [ '_' + p ] = newValue ;
66- //@ts -ignore
67- if ( this . constructor . _enableBindings )
68- this . _bindingsRefresh ( p ) ;
69- instance . dispatchEvent ( new CustomEvent ( camelToDashCase ( p ) + '-changed' , { detail : { newValue } } ) ) ;
70- }
71- } ,
72- enumerable : true ,
73- configurable : true ,
74- } ) ;
75- if ( props [ p ] . default ) {
76- instance [ '_' + p ] = props [ p ] . default ;
54+ if ( window [ name ] ) {
55+ window [ name ] . template = undefined ;
56+ //window[name].style = style;
57+ window [ name ] . properties = props ;
58+ window [ name ] . _propertiesDictionary = null ;
59+ window [ name ] . _enableBindings = this . enableBindings ;
60+ } else {
61+ window [ name ] = function ( ) {
62+ if ( window [ name ] . template === undefined )
63+ window [ name ] . template = definingElement . querySelector ( 'template' ) ;
64+ const instance = Reflect . construct ( BaseDeclaritiveWebcomponent , [ ] , window [ name ] ) ;
65+
66+ for ( let p in props ) {
67+ Object . defineProperty ( instance , p , {
68+ get ( ) {
69+ return this [ '_' + p ] ;
70+ } ,
71+ set ( newValue ) {
72+ if ( this [ '_' + p ] !== newValue ) {
73+ this [ '_' + p ] = newValue ;
74+ //@ts -ignore
75+ if ( this . constructor . _enableBindings )
76+ this . _bindingsRefresh ( p ) ;
77+ instance . dispatchEvent ( new CustomEvent ( camelToDashCase ( p ) + '-changed' , { detail : { newValue } } ) ) ;
78+ }
79+ } ,
80+ enumerable : true ,
81+ configurable : true ,
82+ } ) ;
83+ if ( props [ p ] . default ) {
84+ instance [ '_' + p ] = props [ p ] . default ;
85+ }
7786 }
87+ return instance ;
7888 }
79- return instance ;
80- }
8189
82- //window[name].style = style;
83- window [ name ] . properties = props ;
84- window [ name ] . _propertiesDictionary = null ;
85- window [ name ] . _enableBindings = this . enableBindings ;
86- window [ name ] . prototype = Object . create ( BaseDeclaritiveWebcomponent . prototype , { constructor : { value : window [ name ] } } )
87- if ( ! customElements . get ( name ) )
88- customElements . define ( name , window [ name ] ) ;
90+ //window[name].style = style;
91+ window [ name ] . properties = props ;
92+ window [ name ] . _propertiesDictionary = null ;
93+ window [ name ] . _enableBindings = this . enableBindings ;
94+ window [ name ] . prototype = Object . create ( BaseDeclaritiveWebcomponent . prototype , { constructor : { value : window [ name ] } } )
95+ if ( ! customElements . get ( name ) )
96+ customElements . define ( name , window [ name ] ) ;
97+ }
8998 }
9099}
91100
0 commit comments