Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

HTML comments nested within option tags are copied into choices items #1231

Closed
ActuallyACat opened this issue Nov 28, 2024 · 0 comments · Fixed by #1244
Closed

HTML comments nested within option tags are copied into choices items #1231

ActuallyACat opened this issue Nov 28, 2024 · 0 comments · Fixed by #1244
Labels

Comments

@ActuallyACat
Copy link

Describe the bug
When there are HTML comments within select options, this content is copied into the choices items.

For my particular use case, the initial select and option tags are generated by Lit which adds some metadata in the form of HTML comments to manage dynamic content.
E.g.

<select>
  <!--?lit$486671054$--><!---->
  <option value="asl"><!--?lit$486671054$-->American Sign Language</option>
  <!---->
</select>

To Reproduce
I've made a minimal reproduction in Codepen: https://codepen.io/actuallyacat/pen/WbeNWeg

Or you can refer to this snippet:

<select id="choices-example" class="form-control" placeholder="This is a placeholder" multiple>
  <option value="">
    <!-- HTML comment 1 -->
    Select an option
  </option>
  <option value="dog">
    <!-- HTML comment 2 -->
    Dog
  </option>
</select>
<script> 
document.addEventListener('DOMContentLoaded', function() {
  let choicesConfig = new Choices('#choices-example');
});
</script>

Expected behavior
I would expect that any non-text content within the options would be filtered out.

Screenshots
Screenshot 2024-11-28 at 11 28 04 AM

Choices version and bundle

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

Successfully merging a pull request may close this issue.

1 participant