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

Method add

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

Add a new option to the element. Can specify `value`, `html` content, and `text`. The `before` parameter can be an `Element` or index to insert before. The `**kwargs` are additional arbitrary attributes for the new option element.

(self, value=None, html=None, text=None, before=None, **kwargs)

Source from the content-addressed store, hash-verified

940 return self.options[self._element._dom_element.selectedIndex]
941
942 def add(self, value=None, html=None, text=None, before=None, **kwargs):
943 """
944 Add a new option to the element.
945
946 Can specify `value`, `html` content, and `text`. The `before` parameter can
947 be an `Element` or index to insert before. The `**kwargs` are additional
948 arbitrary attributes for the new option element.
949 """
950 if value:
951 kwargs["value"] = value
952 if html:
953 kwargs["innerHTML"] = html
954 if text:
955 kwargs["text"] = text
956
957 # The `option` element class is dynamically created below.
958 new_option = option(**kwargs) # noqa: F821
959
960 if before and isinstance(before, Element):
961 before = before._dom_element
962
963 self._element._dom_element.add(new_option._dom_element, before)
964
965 def clear(self):
966 """

Callers

nothing calls this directly

Calls 1

addMethod · 0.45

Tested by

no test coverage detected