holtwick / zeed-dom

🌱 Lightweight offline DOM
MIT License
31 stars 6 forks source link

Script content affects parsing #13

Open yurtsiv opened 3 weeks ago

yurtsiv commented 3 weeks ago

The following HTML

<script type="text/javascript">
   1 < 2
</script>

<div>Test</div>

is incorrectly parsed into

_VDocumentFragment "                                                                                                                                                                                        
   <script type="text/javascript">                                                                                                                                                                              
      1 <div>Test</div>                                                                                                                                                                                                                                                                                                                                                                                                  
   </script>"

When < is removed from the JS snippet it parses fine.

I know your parser is minimalistic and doesn't aim for completeness, but would it be possible to treat script content as text and not try to detect HTML tags in there?

holtwick commented 3 weeks ago

Sure, good idea. I guess the same will be true for <style>.

Anyway, cannot promise to solve it too soon, but it is now on my list :)