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

Need an idiomatic way to insert HTML text #192

Open
lacikawiz opened this issue Jun 17, 2021 · 0 comments
Open

Need an idiomatic way to insert HTML text #192

lacikawiz opened this issue Jun 17, 2021 · 0 comments

Comments

@lacikawiz
Copy link

Currently, the variables and string constants are inserted using the innerText property. This causes HTML encoded elements like   or &raquo to show up as the code, and not as a space or » character.

There's a hacky way to make that happen using the innerHTML property, like this:
<th innerHTML="&raquo;">

However, this is not in the documentation and is more of a workaround than a standard way of doing it.

It also does not offer a way to insert the HTML without adding another level to the DOM tree.

There should be a way to insert HTML from a variable or expression without adding an extra element.

For example something like this:

// this can be coming from an API call
let price= "<del>$11.95</del><ins>$9.99</ins>"  
<div>
  "Price: ", HTML price
  <button> "Add to Cart

Where HTML would be a special function or construct to add the content of the price as HTML.

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

No branches or pull requests

1 participant