@@ -36,6 +36,33 @@ export function Element({ model }) {
36
36
}
37
37
}
38
38
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
+
39
66
function StandardElement ( { model } ) {
40
67
const config = React . useContext ( LayoutConfigContext ) ;
41
68
const children = elementChildren ( model . children ) ;
@@ -95,33 +122,6 @@ function RenderImportedElement({ model, importSource }) {
95
122
return html `< div ref =${ mountPoint } / > ` ;
96
123
}
97
124
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
-
125
125
function eventHandler ( sendEvent , eventSpec ) {
126
126
return function ( ) {
127
127
const data = Array . from ( arguments ) . map ( ( value ) => {
@@ -152,7 +152,11 @@ function loadImportSource(config, importSource) {
152
152
return {
153
153
data : importSource ,
154
154
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 ) ;
156
160
if (
157
161
typeof binding . render == "function" &&
158
162
typeof binding . unmount == "function"
0 commit comments