dotnet-websharper / ui

A reactive UI library for WebSharper.
https://websharper-samples.github.io/ui/
Apache License 2.0
77 stars 22 forks source link

Templating breaks inside <table> #216

Closed granicz closed 3 years ago

granicz commented 3 years ago

See https://gitter.im/intellifactory/websharper?at=5fee8364acd1e516f8c71ee7 for details

(only tested in SPAs with Bind())

granicz commented 3 years ago

@Tarmil Can you take a look? Thanks!

Tarmil commented 3 years ago

I think that's because HTML is actually parsed weirdly by browsers (as a standard) when some forbidden nestings happen, such as in your case div directly inside tbody or tr directly inside div. There is some code that helps deal with it in sitelets, based on this article, but if your SPA page contains these combinations then there is nothing that WebSharper can do.

So what you need to do is remove the divs and move the ws-* attributes around so that the final effect is the same but the structure looks like valid HTML, for example something like this:

<table>
    <tbody ws-hole="CartItems" ws-children-template="CartItem">
        <tr>
            <td ...>

Or this:

<table>
    <tbody>
        <tr ws-replace="CartItems"></tr>
        <tr ws-template="CartItem">
            <td ...>