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

Function _find_by_id

core/src/stdlib/pyscript/web.py:218–227  ·  view source on GitHub ↗

Find an element by `id` within a `dom_node`. The `target_id` can optionally start with '#'. Returns a wrapped `Element` or `None` if not found.

(dom_node, target_id)

Source from the content-addressed store, hash-verified

216
217
218def _find_by_id(dom_node, target_id):
219 """
220 Find an element by `id` within a `dom_node`.
221
222 The `target_id` can optionally start with '#'. Returns a wrapped `Element`
223 or `None` if not found.
224 """
225 element_id = target_id[1:] if target_id.startswith("#") else target_id
226 result = dom_node.querySelector(f"#{element_id}")
227 return _wrap_if_not_none(result)
228
229
230def _find_and_wrap(dom_node, selector):

Callers 3

__getitem__Method · 0.85
__getitem__Method · 0.85
__getitem__Method · 0.85

Calls 1

_wrap_if_not_noneFunction · 0.85

Tested by

no test coverage detected