Why do getHtml() and getOuterHtml() only work on the first child?
Closed this issue · 1 comments
matthijskooijman commented
Today, I tried returning a NodeList of DomElements from a function, to allow callers to either include it in a DOM tree, or call ->getOuterHtml()
on it to process the elements as an HTML string.
However, I found that this actually only returns the HTML of the first element of the nodelist:
php-dom-wrapper/src/Traits/ManipulationTrait.php
Lines 684 to 688 in 5243c72
The same thing happens for getHTML()
:
php-dom-wrapper/src/Traits/ManipulationTrait.php
Lines 693 to 697 in 5243c72
Why is this? Wouldn't it make more sense to add an additional reduce()
instead of the first()
to iterate all elements of the collection?
matthijskooijman commented
Thanks!