* Create table element. * * @param {string} className The CSS classes to add. * @returns {object}
(className = '')
| 476 | * @returns {object} |
| 477 | */ |
| 478 | createTable(className = ''): GhostTableStruct { |
| 479 | const rootDocument = this.hot!.rootDocument; |
| 480 | const fragment = rootDocument.createDocumentFragment(); |
| 481 | const table = rootDocument.createElement('table'); |
| 482 | const tHead = rootDocument.createElement('thead'); |
| 483 | const tBody = rootDocument.createElement('tbody'); |
| 484 | const colGroup = rootDocument.createElement('colgroup'); |
| 485 | const tr = rootDocument.createElement('tr'); |
| 486 | const th = rootDocument.createElement('th'); |
| 487 | |
| 488 | if (this.isVertical()) { |
| 489 | table.appendChild(colGroup); |
| 490 | } |
| 491 | if (this.isHorizontal()) { |
| 492 | tr.appendChild(th); |
| 493 | tHead.appendChild(tr); |
| 494 | table.style.tableLayout = 'auto'; |
| 495 | table.style.width = 'auto'; |
| 496 | } |
| 497 | table.appendChild(tHead); |
| 498 | |
| 499 | if (this.isVertical()) { |
| 500 | tBody.appendChild(tr); |
| 501 | } |
| 502 | table.appendChild(tBody); |
| 503 | addClass(table, className); |
| 504 | fragment.appendChild(table); |
| 505 | |
| 506 | return { fragment, table, tHead, tBody, colGroup, tr, th }; |
| 507 | } |
| 508 | |
| 509 | /** |
| 510 | * Create container for tables. |
no test coverage detected