Closed walsha2 closed 3 months ago
Update - as with seemingly all of my recent issues, this problem is isolated to client only apps.
Thanks for this issue.
You are right that right now rawHtml
is not well working on the client, especially when used along sibling components.
I like the proposal of using a separate raw()
method and removing the rawHtml
flag from the text component.
Description
I am not seeing a very clear and obvious way to directly inject HTML into the DOM. Basically I just want to take a string and have it be placed in the DOM at a specific location, without any sort of manipulation from
jaspr
.My expectation is that this would be the way to do it:
However, when trying to use this on simple or complicating raw HTML strings I keep seeing all sorts of side effects. The
rawHtml
flag is doing something odd to the resulting HTML and interfering with other elements.Steps To Reproduce
See the repo below, on the
raw-html
branch for a complete working example and aREADME
with other context:https://github.com/walsha2/jaspr-issues/tree/raw-html
Feedback
Injecting raw HTML should have first class support. Sometimes there are chucks of raw HTML code that we just want to copy (e.g. an
svg
with manypath
components) and insert into the DOM without needing to fist manually convert in thejaspr
native components, which can be tedious. I had to do this for ansvg
and it was not fun.Using
text('...',rawHtml: true)
seems a bit like a second class feature? I know it sounds trivial, but something likeraw('...')
seems to make more sense. Maybe this even bypasses the entireComponent
processing to ensure that there are no unintended side effects to the raw code. Im sure that is what the intent ofrawHtml
flag is doing, but it seems like that might not be the case as evidenced by this bug.The docs for
text
state "Utility method to create a text component when using jaspr html methods" and that does not sounds like what I want to do necessarily. It could just be a matter of semantics, but this isn't a "text component", it is a raw DOM element and I do not want it to use any "jaspr html methods".