-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
delete function has bug #88
Comments
Can you give a example html, so that we can create a unit test out of it, thx? |
I got same error. You can try this code
|
@trananhmanh89 your HTML is broken |
Oh, sorry. You can try this code again
|
@voku, i found out that, this issue because simple dom doesn't apply the changes to root dom if you switch context to child element. And also always create a new HtmlDomParser each time you find, findOne, or findMulti. |
I'm having the same issue: $dom = HtmlDomParser::str_get_html('<html><form><input name="test"></form></html>');
$form = $dom->findOne('form'); // first findOne()
$input = $form->findOne('input'); // nested findOne()
$input->name = 'FOO'; // mutation
echo str($dom); // does not see the change! @voku To be clear, what is the correct way to perform this change? I cannot avoid the two nested calls, because in my real code they are not findOne(), but loops over all results of find(): foreach ($dom->find('form') as $form) {
// ... analyze form
foreach ($form->find('input') as $input) {
// ... mutate each input
}
}
echo str($dom); // does not see mutations done to inputs! |
Anyone have a solution to this? I too am facing a similar issue as @tobia. I need to loop through and preform changes to child elements. |
What is this feature about (expected vs actual behaviour)?
delete function has bug
How can I reproduce it?
$dom = HtmlDomParser::str_get_html($html);
$body = $dom->findOne("body");
$body->findOne("img")->delete();
Image is not deleted.
Image is deleted is only delete if using: $dom->findOne("img")->delete();
Does it take minutes, hours or days to fix?
minutes
Any additional information?
The text was updated successfully, but these errors were encountered: