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

verbatim shouldn't create a wrapper div #200

Closed
ajusa opened this issue May 8, 2021 · 7 comments
Closed

verbatim shouldn't create a wrapper div #200

ajusa opened this issue May 8, 2021 · 7 comments
Labels

Comments

@ajusa
Copy link
Collaborator

ajusa commented May 8, 2021

Using verbatim shouldn't cause a wrapper div to be created, it isn't always the desired behavior.
#160 tries addressing this with a new verbatimRaw, but I would suggest just not having verbatim create a div at all, it is super easy for the user to add a wrapper div if needed. Also, verbatim must have a parent HTML element anyway.

I'd also argue that it is pretty unintuitive for a hidden element to be created if you just want to display something like & properly.

@ajusa ajusa added the bug label May 8, 2021
@Araq
Copy link
Collaborator

Araq commented May 8, 2021

Agreed.

@timotheecour
Copy link
Collaborator

agreed; if you have a working PR that avoids creating a div with verbatim, then #160 can be closed

@jyapayne
Copy link
Contributor

#160 is incorrect anyways. Example:

let node = "This is an inner div <div>inner div</div>".verbatimRaw
# node == VNode("This is an inner div ")

It completely discards any other children. You probably shouldn't do this anyways (not the point of verbatim), but it also shouldn't result in discarded data.

The reason why verbatim currently uses a div is because of the above. To capture many children in one node. The way around this would be to make toDom return a list of nodes and all the places that call it be modified to handle a list of nodes. Then the surrounding div for verbatim could be removed.

@dom96
Copy link
Contributor

dom96 commented May 23, 2021

I recall that React has a special <>/</> syntax. Maybe we could similarly create a special "empty" node which allows a list of nodes to be returned without any additional tags being output?

@jyapayne
Copy link
Contributor

Hmm, that could work as well

@hamidb80
Copy link

other frameworks append custom html comments to solve this problem iirc:

<!-- start arbitrary text #1 -->
...
<!-- end arbitrary text #1 -->

@geotre
Copy link
Collaborator

geotre commented Oct 20, 2023

Completed in #270

@geotre geotre closed this as completed Oct 20, 2023
geotre added a commit that referenced this issue Oct 21, 2023
geotre added a commit that referenced this issue Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants