MCPcopy Index your code
hub / github.com/pyscript/pyscript / decorator

Function decorator

core/src/stdlib/pyscript/events.py:156–175  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

154 raise ValueError(f"No elements found for selector: {selector}")
155
156 def decorator(func):
157 wrapper = _create_wrapper(func)
158 if isinstance(event_type, Event):
159 # Custom Event - add listener.
160 event_type.add_listener(wrapper)
161 elif isinstance(event_type, list) and all(
162 isinstance(t, Event) for t in event_type
163 ):
164 # List of custom Events - add listener to each.
165 for event in event_type:
166 event.add_listener(wrapper)
167 else:
168 # DOM event - attach to all matched elements.
169 for element in elements:
170 element.addEventListener(
171 event_type,
172 create_proxy(wrapper),
173 to_js(options) if options else False,
174 )
175 return wrapper
176
177 return decorator
178

Callers

nothing calls this directly

Calls 4

create_proxyFunction · 0.90
to_jsFunction · 0.90
_create_wrapperFunction · 0.85
add_listenerMethod · 0.80

Tested by

no test coverage detected