You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to suggest a feature enhancement for the library. When using the insertHTML method, it would be incredibly useful to have a built-in parameter that automatically preserves attributes from the original document.
Currently, when insertHTML is used, attributes such as lang on the tag are overwritten by the new HTML content. This can lead to issues where important document settings are unintentionally lost. For example, consider the following scenario:
$dom = new IvoPetkov\HTML5DOMDocument();
$dom->loadHTML('<!DOCTYPE html><html lang="en"><body><h1>Hello</h1><div class="content">This is some text</div></body></html>', IvoPetkov\HTML5DOMDocument::ALLOW_DUPLICATE_IDS);
$dom->insertHTML('<!DOCTYPE html><html lang="ca"><body><h1>Hello</h1><div class="content">Another text</div></body></html>');
echo $dom->saveHTML();
In this case, the lang attribute is changed from "en" to "ca", which might not be the desired outcome. To handle this, a typical workaround involves manually saving and restoring the attributes, which adds complexity to the code.
I propose adding an option to insertHTML that preserves the existing attributes from the original document, making it easier for users to maintain document settings without additional manual steps.
Cheers,
The text was updated successfully, but these errors were encountered:
Hi,
I would like to suggest a feature enhancement for the library. When using the insertHTML method, it would be incredibly useful to have a built-in parameter that automatically preserves attributes from the original document.
Currently, when insertHTML is used, attributes such as lang on the tag are overwritten by the new HTML content. This can lead to issues where important document settings are unintentionally lost. For example, consider the following scenario:
In this case, the lang attribute is changed from "en" to "ca", which might not be the desired outcome. To handle this, a typical workaround involves manually saving and restoring the attributes, which adds complexity to the code.
I propose adding an option to insertHTML that preserves the existing attributes from the original document, making it easier for users to maintain document settings without additional manual steps.
Cheers,
The text was updated successfully, but these errors were encountered: