25
25
EventHandlerType ,
26
26
ImportSourceDict ,
27
27
JavaScript ,
28
- JSExecutableDict ,
28
+ InlineJavascriptDict ,
29
29
VdomAttributes ,
30
30
VdomChildren ,
31
31
VdomDict ,
32
32
VdomJson ,
33
33
)
34
34
35
- EVENT_ATTRIBUTE_PATTERN = re .compile (r"^on\w+" )
35
+ EVENT_ATTRIBUTE_PATTERN = re .compile (r"^on[A-Z] \w+" )
36
36
37
37
VDOM_JSON_SCHEMA = {
38
38
"$schema" : "http://json-schema.org/draft-07/schema" ,
47
47
"children" : {"$ref" : "#/definitions/elementChildren" },
48
48
"attributes" : {"type" : "object" },
49
49
"eventHandlers" : {"$ref" : "#/definitions/elementEventHandlers" },
50
- "jsExecutables " : {"$ref" : "#/definitions/elementJSExecutables " },
50
+ "inlineJavascript " : {"$ref" : "#/definitions/elementInlineJavascripts " },
51
51
"importSource" : {"$ref" : "#/definitions/importSource" },
52
52
},
53
53
# The 'tagName' is required because its presence is a useful indicator of
77
77
},
78
78
"required" : ["target" ],
79
79
},
80
- "elementJSExecutables " : {
80
+ "elementInlineJavascripts " : {
81
81
"type" : "object" ,
82
82
"patternProperties" : {
83
83
".*" : "str" ,
@@ -172,8 +172,8 @@ def __call__(
172
172
"""The entry point for the VDOM API, for example reactpy.html(<WE_ARE_HERE>)."""
173
173
attributes , children = separate_attributes_and_children (attributes_and_children )
174
174
key = attributes .get ("key" , None )
175
- attributes , event_handlers , js_executables = (
176
- separate_attributes_handlers_and_executables (attributes )
175
+ attributes , event_handlers , inline_javascript = (
176
+ separate_attributes_handlers_and_inline_javascript (attributes )
177
177
)
178
178
if REACTPY_CHECK_JSON_ATTRS .current :
179
179
json .dumps (attributes )
@@ -194,7 +194,7 @@ def __call__(
194
194
** ({"children" : children } if children else {}),
195
195
** ({"attributes" : attributes } if attributes else {}),
196
196
** ({"eventHandlers" : event_handlers } if event_handlers else {}),
197
- ** ({"jsExecutables " : js_executables } if js_executables else {}),
197
+ ** ({"inlineJavascript " : inline_javascript } if inline_javascript else {}),
198
198
** ({"importSource" : self .import_source } if self .import_source else {}),
199
199
}
200
200
@@ -227,26 +227,26 @@ def separate_attributes_and_children(
227
227
return _attributes , _children
228
228
229
229
230
- def separate_attributes_handlers_and_executables (
230
+ def separate_attributes_handlers_and_inline_javascript (
231
231
attributes : Mapping [str , Any ],
232
- ) -> tuple [VdomAttributes , EventHandlerDict , JSExecutableDict ]:
232
+ ) -> tuple [VdomAttributes , EventHandlerDict , InlineJavascriptDict ]:
233
233
_attributes : VdomAttributes = {}
234
234
_event_handlers : dict [str , EventHandlerType ] = {}
235
- _js_executables : dict [str , JavaScript ] = {}
235
+ _inline_javascript : dict [str , JavaScript ] = {}
236
236
237
237
for k , v in attributes .items ():
238
238
if callable (v ):
239
239
_event_handlers [k ] = EventHandler (to_event_handler_function (v ))
240
240
elif isinstance (v , EventHandler ):
241
241
_event_handlers [k ] = v
242
242
elif EVENT_ATTRIBUTE_PATTERN .match (k ) and isinstance (v , str ):
243
- _js_executables [k ] = JavaScript (v )
243
+ _inline_javascript [k ] = JavaScript (v )
244
244
elif isinstance (v , JavaScript ):
245
- _js_executables [k ] = v
245
+ _inline_javascript [k ] = v
246
246
else :
247
247
_attributes [k ] = v
248
248
249
- return _attributes , _event_handlers , _js_executables
249
+ return _attributes , _event_handlers , _inline_javascript
250
250
251
251
252
252
def _flatten_children (children : Sequence [Any ]) -> list [Any ]:
0 commit comments