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

Tables with rowspan or colspan is treated as invalid table #7

Open
diesburgm opened this issue Dec 6, 2019 · 2 comments
Open

Tables with rowspan or colspan is treated as invalid table #7

diesburgm opened this issue Dec 6, 2019 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@diesburgm
Copy link

Add the following test.

[
  'table - with colspan',
  htmlToFragment('<table><tbody><tr><td>one</td><td>two</td></tr><tr><td colspan="2">col span</td></tr></tbody></table>'),
  htmlToFragment('<table><tbody><tr><td>one</td><td>two</td></tr><tr><td colspan="2">col span</td></tr></tbody></table>'),
  '<table><tbody><tr><td>one</td><td>two</td></tr><tr><td colspan="2"</td></tr></tbody></table>',
  undefined,
],

Unit test fails.

Expected: "

<td colspan="2"
onetwo
"
Received: "<table class="vdd-removed">onetwo<td colspan="2" <="" td=""><table class="vdd-added">onetwo<td colspan="2" <="" td="">"

@gkubisa gkubisa added the enhancement New feature or request label Dec 9, 2019
@gkubisa
Copy link
Contributor

gkubisa commented Dec 9, 2019

This is a known limitation - colspan and rowspan present and not equal to "1" make visual-dom-diff bail out and show that the old table was removed and a new one added.

The problem is with keeping columns always properly aligned which is really necessary to make diffs understandable to users. Given the complexity of this task, I decided to focus on the most common case first and bail out in case certain preconditions are not met, one of which is colspan and rowspan must equal 1.

It is definitely possible to extend the base algorithm to handle colspan and rowspan greater than 1, at least in some cases, though it might still be necessary to place some restrictions in order to keep the result user-friendly. Unfortunately, I won't have time to implement it any time soon but I'd certainly welcome a PR.

@humitos
Copy link

humitos commented Jul 18, 2024

I just found this issue and I'm not sure to understand if I'm hitting the same issue one or not.

I used the following HTML snippet to test it:

<table>
<thead>
<tr><th>Environment variable</th>
<th>Zope option</th>
<th>Default value</th>
</tr>
</thead>
<tbody>
<tr><td>DEBUG_MODE</td>
<td>debug-mode</td>
<td>off</td>
</tr>
</tbody>
</table>

I paste it twice in https://teamwork.github.io/visual-dom-diff/ and I'm seeing the whole table being deleted and added. Am I doing something wrong here?

Would you mind pointing me to the section of the code where this behavior could be happening? I may be able to take a look and see if I find something relevant to make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants