question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTMLTableElement.prototype.rows does not reflect reality until length called

See original GitHub issue

I wasn’t able to reproduce this immediately in a clean test case to share, but I stumbled upon an issue where table.deleteRow(0) does not change table.rows indices until table.rows.length is accessed.

Took me a while to understand that this was happening. A kind of a heisenbug.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TimothyGucommented, Aug 21, 2017

Yes it’s fixed! Did have to change the test to account for automatic tbody adding though:

const { JSDOM } = require(".");

const html = `
<table id="table">
  <tbody>
    <tr><td>Cell 1</td></tr>
    <tr><td>Cell 2</td></tr>
  </tbody>
</table>
<script>
  var table = document.getElementById('table');
  var tbody = table.children[0];

  console.log(table.rows[0].cells[0].textContent);

  var row1 = table.rows[0];
  tbody.removeChild(row1);
  tbody.appendChild(row1);

  console.log(table.rows[0].cells[0].textContent);

  table.rows.length;

  console.log(table.rows[0].cells[0].textContent);
</script>
`;

new JSDOM(html, { runScripts: 'dangerously' });

now outputs

Cell 1
Cell 2
Cell 2

as expected.

1reaction
domeniccommented, Aug 21, 2017

Should be fixed by https://github.com/tmpvar/jsdom/pull/1934, although we should add specific tests to confirm the caching isn’t messing us up somehow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTMLTableElement - Web APIs | MDN
Chrome Edge HTMLTableElement Full support. Chrome1. Toggle history Full support. Edge12. Toggle hi... align. Deprecated Full support. Chrome1. Toggle history Full support. Edge12. Toggle hi... bgColor....
Read more >
HTML Standard
If the given time is NaN, then the result is a Date object that represents a time value NaN (indicating that the object...
Read more >
HTML 5.2: 2. Common infrastructure - W3C
Also, the SVG specifications do not reflect implementation reality. Implementations implement subsets of SVG 1.1 and SVG Tiny 1.2.
Read more >
Safari Technology Preview Release Notes - Apple Developer
Note: Tab Groups do not sync in this release. Web Inspector. Sources Tab. Enabled automatic collapsing of blackboxed call frames (r288580). Network Tab....
Read more >
DOM Enlightenment - Exploring the relationship between ...
This book is not an exhaustive reference on DOM scripting or JavaScript. ... The collections have a length property that reflects the number...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found