@@ -36,6 +36,33 @@ export function Element({ model }) {
3636 }
3737}
3838
39+ export function elementChildren ( modelChildren ) {
40+ if ( ! modelChildren ) {
41+ return [ ] ;
42+ } else {
43+ return modelChildren . map ( ( child ) => {
44+ switch ( typeof child ) {
45+ case "object" :
46+ return html `< ${ Element } key =${ child . key } model=${ child } /> ` ;
47+ case "string" :
48+ return child ;
49+ }
50+ } ) ;
51+ }
52+ }
53+
54+ export function elementAttributes ( model , sendEvent ) {
55+ const attributes = Object . assign ( { } , model . attributes ) ;
56+
57+ if ( model . eventHandlers ) {
58+ for ( const [ eventName , eventSpec ] of Object . entries ( model . eventHandlers ) ) {
59+ attributes [ eventName ] = eventHandler ( sendEvent , eventSpec ) ;
60+ }
61+ }
62+
63+ return attributes ;
64+ }
65+
3966function StandardElement ( { model } ) {
4067 const config = React . useContext ( LayoutConfigContext ) ;
4168 const children = elementChildren ( model . children ) ;
@@ -95,33 +122,6 @@ function RenderImportedElement({ model, importSource }) {
95122 return html `< div ref =${ mountPoint } / > ` ;
96123}
97124
98- export function elementChildren ( modelChildren ) {
99- if ( ! modelChildren ) {
100- return [ ] ;
101- } else {
102- return modelChildren . map ( ( child ) => {
103- switch ( typeof child ) {
104- case "object" :
105- return html `< ${ Element } key =${ child . key } model=${ child } /> ` ;
106- case "string" :
107- return child ;
108- }
109- } ) ;
110- }
111- }
112-
113- export function elementAttributes ( model , sendEvent ) {
114- const attributes = Object . assign ( { } , model . attributes ) ;
115-
116- if ( model . eventHandlers ) {
117- for ( const [ eventName , eventSpec ] of Object . entries ( model . eventHandlers ) ) {
118- attributes [ eventName ] = eventHandler ( sendEvent , eventSpec ) ;
119- }
120- }
121-
122- return attributes ;
123- }
124-
125125function eventHandler ( sendEvent , eventSpec ) {
126126 return function ( ) {
127127 const data = Array . from ( arguments ) . map ( ( value ) => {
@@ -152,7 +152,11 @@ function loadImportSource(config, importSource) {
152152 return {
153153 data : importSource ,
154154 bind : ( node ) => {
155- const binding = module . bind ( node , config ) ;
155+ const shortImportSource = {
156+ source : importSource . source ,
157+ sourceType : importSource . sourceType ,
158+ } ;
159+ const binding = module . bind ( node , config , shortImportSource ) ;
156160 if (
157161 typeof binding . render == "function" &&
158162 typeof binding . unmount == "function"
0 commit comments