Skip to content

Use normal index deletion for child nodes - #229

Open
CodingFeng101 wants to merge 1 commit into
Knio:masterfrom
CodingFeng101:codex/delete-child-index
Open

CodingFeng101 wants to merge 1 commit into
Knio:masterfrom
CodingFeng101:codex/delete-child-index

Conversation

@CodingFeng101

Copy link
Copy Markdown

What changed

dom_tag.delete_attribute() now deletes child nodes with normal list index semantics when the key is an integer.

Why

Child reads and assignments already use normal list indexing: negative indexes work, and out-of-range indexes raise. Deletion was the odd path because it used a slice (key:key+1), which made del tag[10] silently do nothing and made del tag[-1] fail to remove the last child.

This keeps attribute deletion unchanged and only changes the integer child-index path.

Validation

  • Reproduced locally before the change: del div("a", "b")[10] did not raise, and delete_attribute(-1) did not remove the last child.
  • python -m pytest tests\test_dom_tag.py::test_delete_attribute_child_index tests\test_dom_tag.py::test_set_attribute tests\test_html.py::test_add -q
  • python -m pytest tests -q
  • python -m py_compile dominate\dom_tag.py tests\test_dom_tag.py
  • git diff --check

Note: the repository-wide python -m pytest -q also collects README doctests locally; that currently fails on README doctest context setup (d is not defined), while the package test suite under tests passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant