ivi icon indicating copy to clipboard operation
ivi copied to clipboard

@ivi/htm: whitespace between dynamic bits disappears

Open leeoniya opened this issue 1 year ago • 4 comments

@localvoid

`
${table.schema.cols.map((c, i) => html`
  <th @click=${() => onClickCol(i)}>
    ${c.name}
    ${sortDir[i] || ''}
    ${sortPos[i] || ''}
  </th>
`)}
`

creates 3 adjacent text nodes with no white space between:

<th>genre11</th>

image

also behaves a bit differently when in single line:

`
${table.schema.cols.map((c, i) => html`
  <th @click=${() => onClickCol(i)}>${c.name} ${sortDir[i] || ''} ${sortPos[i] || ''}</th>
`)}
`
<th>title <!---->11</th>

image

leeoniya avatar Dec 29 '23 01:12 leeoniya

inserting &nbsp; in between doesn't quite work, either:

`
${table.schema.cols.map((c, i) => html`
  <th @click=${() => onClickCol(i)}>
    ${c.name}
    &nbsp;
    ${sortDir[i] || ''}
    &nbsp;
    ${sortPos[i] || ''}
  </th>
`)}
`
<th>genre&nbsp;<!---->11</th>

image

leeoniya avatar Dec 29 '23 01:12 leeoniya

@localvoid any chance of getting this patched?

leeoniya avatar Apr 30 '24 00:04 leeoniya

I'll try to figure out what causing this issue and fix it next week, but I am not sure that I'll have a lot of time to work on this project.

localvoid avatar Apr 30 '24 00:04 localvoid

I'll try to figure out what causing this issue and fix it next week

thanks :)

but I am not sure that I'll have a lot of time to work on this project.

that's too bad :(, but i get it.

leeoniya avatar Apr 30 '24 00:04 leeoniya

@localvoid ping :pray:

leeoniya avatar May 26 '24 20:05 leeoniya

Released a new version that should fix the bug with a comment node.

The first example with newlines works as expected, by default all whitespaces around newlines between elements and expressions are removed (https://github.com/localvoid/ivi/blob/master/packages/@ivi/htm/README.md#whitespaces). There is a workaround with vertical tab \v for such use cases:

`
${table.schema.cols.map((c, i) => html`
  <th @click=${() => onClickCol(i)}>
    ${c.name}
    \v${sortDir[i] || ''}
    \v${sortPos[i] || ''}
  </th>
`)}
`

localvoid avatar May 27 '24 13:05 localvoid

thanks!

leeoniya avatar Jun 09 '24 00:06 leeoniya