@@ -55,34 +55,45 @@ export function defineCustomElement(win: Window, cmpData: d.ComponentHostData |
5555 ) ;
5656 }
5757
58- // polyfills have been applied if need be
59- ( cmpData as d . ComponentHostData [ ] ) . forEach ( c => {
60- let HostElementConstructor : any ;
61-
62- if ( isNative ( win . customElements . define ) ) {
63- // native custom elements supported
64- const createHostConstructor = new Function ( 'w' , 'return class extends w.HTMLElement{}' ) ;
65- HostElementConstructor = createHostConstructor ( win ) ;
66-
67- } else {
68- // using polyfilled custom elements
69- HostElementConstructor = function ( self : any ) {
70- return ( win as any ) . HTMLElement . call ( this , self ) ;
71- } ;
72-
73- HostElementConstructor . prototype = Object . create (
74- ( win as any ) . HTMLElement . prototype ,
75- { constructor : { value : HostElementConstructor , configurable : true } }
58+ function defineComponents ( ) {
59+ // polyfills have been applied if need be
60+ ( cmpData as d . ComponentHostData [ ] ) . forEach ( c => {
61+ let HostElementConstructor : any ;
62+
63+ if ( isNative ( win . customElements . define ) ) {
64+ // native custom elements supported
65+ const createHostConstructor = new Function ( 'w' , 'return class extends w.HTMLElement{}' ) ;
66+ HostElementConstructor = createHostConstructor ( win ) ;
67+
68+ } else {
69+ // using polyfilled custom elements
70+ HostElementConstructor = function ( self : any ) {
71+ return ( win as any ) . HTMLElement . call ( this , self ) ;
72+ } ;
73+
74+ HostElementConstructor . prototype = Object . create (
75+ ( win as any ) . HTMLElement . prototype ,
76+ { constructor : { value : HostElementConstructor , configurable : true } }
77+ ) ;
78+ }
79+
80+ // convert the static constructor data to cmp metadata
81+ // define the component as a custom element
82+ pltMap [ namespace ] . defineComponent (
83+ buildComponentLoader ( c ) ,
84+ HostElementConstructor
7685 ) ;
77- }
86+ } ) ;
87+ }
7888
79- // convert the static constructor data to cmp metadata
80- // define the component as a custom element
81- pltMap [ namespace ] . defineComponent (
82- buildComponentLoader ( c ) ,
83- HostElementConstructor
84- ) ;
85- } ) ;
89+ if ( _BUILD_ . cssVarShim && ( window as any ) . customStyleShim ) {
90+ pltMap [ namespace ] . customStyle = ( window as any ) . customStyleShim ;
91+
92+ pltMap [ namespace ] . customStyle . initShim ( ) . then ( defineComponents ) ;
93+
94+ } else {
95+ defineComponents ( ) ;
96+ }
8697
8798 } ) ;
8899}
0 commit comments