File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 32
32
VdomJson ,
33
33
)
34
34
35
- EVENT_ATTRIBUTE_PATTERN = re .compile (r"^on[A-Z] " )
35
+ EVENT_ATTRIBUTE_PATTERN = re .compile (r"^on\w+ " )
36
36
37
37
VDOM_JSON_SCHEMA = {
38
38
"$schema" : "http://json-schema.org/draft-07/schema" ,
Original file line number Diff line number Diff line change @@ -790,7 +790,7 @@ class VdomTypeDict(TypedDict):
790
790
children : NotRequired [Sequence [ComponentType | VdomChild ]]
791
791
attributes : NotRequired [VdomAttributes ]
792
792
eventHandlers : NotRequired [EventHandlerDict ]
793
- jsExecutables : NotRequired [JavaScript ]
793
+ jsExecutables : NotRequired [JSExecutableDict ]
794
794
importSource : NotRequired [ImportSourceDict ]
795
795
796
796
@@ -896,6 +896,7 @@ class JsonImportSource(TypedDict):
896
896
897
897
898
898
class JavaScript (str ):
899
+ """A simple way of marking JavaScript code to be executed client-side"""
899
900
pass
900
901
901
902
@@ -937,7 +938,7 @@ class EventHandlerType(Protocol):
937
938
"""A dict mapping between event names to their handlers"""
938
939
939
940
JSExecutableMapping = Mapping [str , JavaScript ]
940
- """A generic mapping between event names to their javascript"""
941
+ """A generic mapping between attribute names to their javascript"""
941
942
942
943
JSExecutableDict : TypeAlias = dict [str , JavaScript ]
943
944
"""A dict mapping between attribute names to their javascript"""
Original file line number Diff line number Diff line change @@ -194,6 +194,15 @@ def test_string_to_reactpy(case):
194
194
"key" : "my-key" ,
195
195
},
196
196
},
197
+ # 9: Includes `jsExecutables` attribue
198
+ {
199
+ "source" : '''<button onclick="this.innerText = 'CLICKED'">Click Me</button>''' ,
200
+ "model" : {
201
+ "tagName" : "button" ,
202
+ "jsExecutables" : {"onclick" : "this.innerText = 'CLICKED'" },
203
+ "children" : ["Click Me" ],
204
+ }
205
+ },
197
206
],
198
207
)
199
208
def test_string_to_reactpy_default_transforms (case ):
You can’t perform that action at this time.
0 commit comments