Append items to this element's `children`. Accepts `Element` instances, `ElementCollection` instances, lists, tuples, raw DOM elements, NodeLists, str, int, float, and bool.
(self, *items)
| 638 | return Element.wrap_dom_element(self._dom_element.parentElement) |
| 639 | |
| 640 | def append(self, *items): |
| 641 | """ |
| 642 | Append items to this element's `children`. |
| 643 | |
| 644 | Accepts `Element` instances, `ElementCollection` instances, lists, |
| 645 | tuples, raw DOM elements, NodeLists, str, int, float, and bool. |
| 646 | """ |
| 647 | for item in items: |
| 648 | if isinstance(item, Element): |
| 649 | self._dom_element.appendChild(item._dom_element) |
| 650 | elif isinstance(item, ElementCollection): |
| 651 | for element in item: |
| 652 | self._dom_element.appendChild(element._dom_element) |
| 653 | elif isinstance(item, (list, tuple)): |
| 654 | for child in item: |
| 655 | self.append(child) |
| 656 | elif hasattr(item, "tagName"): |
| 657 | # Raw DOM element. |
| 658 | self._dom_element.appendChild(item) |
| 659 | elif hasattr(item, "length"): |
| 660 | # NodeList or similar iterable. |
| 661 | for element in item: |
| 662 | self._dom_element.appendChild(element) |
| 663 | elif isinstance(item, (str, int, float, bool)): |
| 664 | self._dom_element.append(item) |
| 665 | else: |
| 666 | raise TypeError(f"Cannot append {type(item).__name__} to element.") |
| 667 | |
| 668 | def clone(self, clone_id=None): |
| 669 | """ |