border-collapse-dynamic-col-001.html (1408B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>CSS Test: Border collapsed table with a dynamic <col> insertion</title> 4 <link rel="help" href="https://drafts.csswg.org/css-tables/#border-collapsing"> 5 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1652384"> 6 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> 7 <link rel="author" title="Mozilla" href="https://mozilla.org"> 8 <link rel="match" href="border-collapse-dynamic-col-001-ref.html"> 9 <style> 10 table { 11 border-collapse: collapse; 12 border-spacing: 0; 13 } 14 td { 15 padding: 10px; 16 border: 1px solid; 17 } 18 </style> 19 <table> 20 <colgroup> 21 <col> 22 <col> 23 <col> 24 </colgroup> 25 <tbody> 26 <tr> 27 <td></td> 28 <td></td> 29 <td></td> 30 </tr> 31 <tr> 32 <td></td> 33 <td></td> 34 <td></td> 35 </tr> 36 <tr> 37 <td></td> 38 <td></td> 39 <td></td> 40 </tr> 41 </tbody> 42 </table> 43 <script> 44 document.querySelector("table").getBoundingClientRect(); 45 // Insert a column at the second position. 46 var trs = document.querySelectorAll("tr"); 47 var col = document.querySelector("col"); 48 col.parentNode.insertBefore(col.cloneNode(true), col.nextSibling); 49 for (var i = 0; i < trs.length; ++i) { 50 var row = trs[i]; 51 var firstCell = row.querySelector("td"); 52 firstCell.parentNode.insertBefore(firstCell.cloneNode(true), firstCell.nextSibling); 53 } 54 </script>