Couldn't help but notice that the HTML you used with the template is different to the other solutions - the additional span elements. Is there any way around this?
I realized this problem, but chose to ignore it for the sake of simplicity. I will edit the post to fix this problem. Thanks!
To fix this, I would replace the entire placeholder <span> with the text, rather than changing its innerText. I'm sure there are other solutions, so let me know if you find one. ;D
Another, much easier, solution would be to replace the <span> elements with <slot> elements. Although slots were made for use with the Shadow DOM, they aren't limited to that. The purpose of a slot is to be replaced, which means it's unlikely that they will be styled.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Couldn't help but notice that the HTML you used with the template is different to the other solutions - the additional
span
elements. Is there any way around this?I realized this problem, but chose to ignore it for the sake of simplicity. I will edit the post to fix this problem. Thanks!
To fix this, I would replace the entire placeholder
<span>
with the text, rather than changing itsinnerText
. I'm sure there are other solutions, so let me know if you find one. ;DAnother, much easier, solution would be to replace the
<span>
elements with<slot>
elements. Although slots were made for use with the Shadow DOM, they aren't limited to that. The purpose of a slot is to be replaced, which means it's unlikely that they will be styled.