Oksydan / falcon

Prestashop starter theme that provides great development experience.
GNU General Public License v3.0
264 stars 63 forks source link

🐛 [BUG] - is_themecore hookActionOutputHTMLBefore broken html output #371

Open tomasz3k opened 10 months ago

tomasz3k commented 10 months ago

Description

I just came out with error when I write template file with <script>let test = '<div></div>';</script> Your hook changed it to <script>let test = '<div></script></section></div>';</script> and browser throwed error Uncaught SyntaxError: Invalid or unexpected token I spend hour to find out solution.

Node.js version

v20.10.0

php version

8.1

OS and it's version

MacOs 14.2.1 (23C71)

Browsers

Chrome

Required module/theme

is_themecore

Reproduction steps

Change 
` $doc->loadHTML(
            '<meta http-equiv="Content-Type" content="charset=utf-8">' . $html,
            LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD 
        );` 

to 
` $doc->loadHTML(
            '<meta http-equiv="Content-Type" content="charset=utf-8">' . $html,
            LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_SCHEMA_CREATE
        );`

Logs

No response

Oksydan commented 10 months ago

Hi @tomasz3k,

thank you for creating an issue. I was able to reproduce the problem. I am adding this to is_themecore roadmap. We came across a lot of problems with DOMDocument. I am not sure but we might get rid of it in is_themecore v5.

tomasz3k commented 10 months ago

I think there should be better way to manipulate HTML. DomDocument is easy but not best. It requires many extra flags to works as expected so it's platform dependant too. I am not sure is it the fastest way to manipulate DOM? Maybe you should just use some regex? It will require extra time for tests. Have a nice day.