MCPcopy Create free account
hub / github.com/handsontable/handsontable / createElements

Method createElements

handsontable/src/tableView.ts:286–325  ·  view source on GitHub ↗

* Prepares DOMElements and adds correct className to the root element. * * @private

()

Source from the content-addressed store, hash-verified

284 * @private
285 */
286 createElements() {
287 const { rootElement, rootDocument } = this.hot;
288 const originalStyle = rootElement.getAttribute('style');
289
290 if (originalStyle) {
291 rootElement.dataset.originalstyle = originalStyle; // needed to retrieve original style in jsFiddle link generator in HT examples. may be removed in future versions
292 }
293
294 addClass(rootElement, 'handsontable');
295
296 this.#table = rootDocument.createElement('table');
297 addClass(this.#table, 'htCore');
298
299 if (this.hot.getSettings().tableClassName) {
300 addClass(this.#table, this.hot.getSettings().tableClassName!);
301 }
302
303 if (this.settings.ariaTags) {
304 setAttribute(this.#table, [
305 A11Y_PRESENTATION()
306 ]);
307
308 setAttribute(rootElement, [
309 A11Y_TREEGRID(),
310 A11Y_ROWCOUNT(-1),
311 A11Y_COLCOUNT(this.hot.countCols()),
312 A11Y_MULTISELECTABLE(),
313 ]);
314 }
315
316 this.THEAD = rootDocument.createElement('thead');
317 this.#table.appendChild(this.THEAD);
318
319 this.TBODY = rootDocument.createElement('tbody');
320 this.#table.appendChild(this.TBODY);
321
322 this.hot.table = this.#table;
323
324 this.hot.container.insertBefore(this.#table, this.hot.container.firstChild);
325 }
326
327 /**
328 * Attaches necessary listeners.

Callers 1

constructorMethod · 0.95

Calls 9

addClassFunction · 0.90
setAttributeFunction · 0.90
A11Y_PRESENTATIONFunction · 0.90
A11Y_TREEGRIDFunction · 0.90
A11Y_ROWCOUNTFunction · 0.90
A11Y_COLCOUNTFunction · 0.90
A11Y_MULTISELECTABLEFunction · 0.90
getSettingsMethod · 0.65
countColsMethod · 0.65

Tested by

no test coverage detected