Commit graph

11 commits

Author SHA1 Message Date
Niels Dossche
c7c6a79bd0
Add support for ParentNode::$children (#18908)
ParentNode::$children returns a HTMLCollection of all directly
descendant child elements of a container.

I had to move around some properties such that the ParentNode property
offsets are always at a fixed offset, to simplify the code.
This also adds the necessary code to deal with GC cycles in
HTMLCollections.
Furthermore, we also disable cloning a HTMLCollection as that never
worked and furthermore it also conflicts with the [[SameObject]] WebIDL
requirement of $children.
2025-06-27 09:03:50 +02:00
Niels Dossche
7f5a888bdb
Change dom_node_is_read_only() to return bool (#16757)
Returning int or zend_result doesn't make sense, it's a yes/no question.
2024-11-11 20:57:52 +01:00
Niels Dossche
65fbf47472
Fix static analysis warning
The condition is already checked at the start of the function, mark this
code properly as unreachable.
2024-10-30 20:55:50 +01:00
Niels Dossche
947e319b76
Fix GH-16594: Assertion failure in DOM -> before
The invalid parent condition can actually happen because PHP's DOM is
allows to get children of e.g. attributes; something normally not
possible.

Closes GH-16597.
2024-10-28 19:32:20 +01:00
Niels Dossche
97546746d0
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16039: Segmentation fault (access null pointer) in ext/dom/parentnode/tree.c
2024-09-25 19:39:49 +02:00
Niels Dossche
9435f4d55b
Throw instead of silently failing when creating a too long text node
Lower branches suffer from this as well but we cannot change the
behaviour there.
We also add NULL checks to check for allocation failure.

Closes GH-15014.
2024-07-21 17:08:06 +02:00
Niels Dossche
d5faf44e90
Remove bogus tree setting code from parentnode/tree.c (#15044)
I don't know why this code was here in the first place, it is present
since the initial implementation. It doesn't make sense because:
1. It would require updating the refcounts if the document wasn't
   actually already set.
2. We enforce that the document is the same as the target document by
   this point, so setting the tree is pointless.
2024-07-21 13:53:12 +02:00
Niels Dossche
29466223d0 Move stricterror fetch to dom_child_removal_preconditions() body 2024-07-20 20:01:55 +02:00
Niels Dossche
74116a4ade Remove impossible condition
The parent's child must exist because otherwise this node could not have
a parent node.
2024-07-20 20:01:55 +02:00
Niels Dossche
80a4783d25
Deduplicate NULL checks in ext/dom (#15015)
This introduces a new helper php_dom_create_nullable_object() that does
the NULL check and puts NULL in return_value. Otherwise it runs
php_dom_create_object(). This deduplicates a bit of code.
2024-07-18 21:20:03 +02:00
Niels Dossche
88da914910 Implement CSS selectors 2024-06-29 13:00:26 -07:00
Renamed from ext/dom/parentnode.c (Browse further)