solid icon indicating copy to clipboard operation
solid copied to clipboard

[solid-js/html] template marker `<!--#--` ends up as attribute value

Open trusktr opened this issue 2 years ago • 0 comments

Describe the bug

When there is a certain attribute such as // on an element,

html`<div
  foo="" // comment (for example from copy/pasted JSX)
></div>`

it causes <!--#-- to be passed as an attribute value in the final result. It also causes the wrong indexes to be accessed on exprs.

Your Example Website or App

https://playground.solidjs.com/anonymous/064f29d2-ff1c-441c-a181-9d05ca503610

Steps to Reproduce the Bug or Issue

see demo, remove the // to fix it. The reason there's a NaN error in Lume is because <!--#-- is sent in via its attributeChangedCallback (pause on the error, find prototype.attributeChangedCallback in the callstack, hover on newVal)

Also instead of removing the // try to remove the second element.

Expected behavior

no errors

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

The second element has troubles with wrong index access of exprs.

// is ok in actual html. This might be a common case that can happen when pasting JSX code, maybe its worth updating the regexes to handle this case.

trusktr avatar Jan 07 '24 09:01 trusktr