Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow for configuration to keep void element / self-closing tag style intact #44

Open
Abdull opened this issue Jun 17, 2021 · 1 comment

Comments

@Abdull
Copy link

Abdull commented Jun 17, 2021

<br /> and <br> are both valid styles in how to express void elements in HTML5.

IvoPetkov\HTML5DOMDocument always converts void-elements-with-slashes to void-elements-without-slashes, e.g.

use IvoPetkov\HTML5DOMDocument;

$dom = new HTML5DOMDocument();
$dom->loadHTML('<!DOCTYPE html><html><body>Hello <br /> another text</body></html>');
$result= $dom->saveHTML();

/* $result
<!DOCTYPE html>
<html><body>Hello <br> another text</body></html>
*/

<br /> was changed to <br>.

Unfortunately, XHTML does not support void-elements-without-slashes. For compatibility with downstream XHMTL parsers, it would be great if IvoPetkov\HTML5DOMDocument keeps the void element style of input elements unchanged.

@ivopetkov
Copy link
Owner

HTML5DomDocument is based on the native DOMDocument library, which automatically makes this conversion (which is great because my library is focused on HTML5).

Maybe it's possible to add some code to keep the slashed, but it will impact the performance (when loading and saving HTML). Would you like to contribute such code, and maybe we can enable it only an option is specified?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants