From 0a017d1b8585c9b76fed4d932872ec4ac95175e8 Mon Sep 17 00:00:00 2001 From: Jason Baker Date: Thu, 31 Oct 2024 20:35:25 -0700 Subject: [PATCH] perf: warap column generator in if --- demo/api.min.js | 16 +++++++++------- demo/index.min.js | 16 +++++++++------- src/auro-table.js | 16 +++++++++------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/demo/api.min.js b/demo/api.min.js index 0e1d021..30dbac9 100644 --- a/demo/api.min.js +++ b/demo/api.min.js @@ -71,16 +71,18 @@ class AuroTable extends LitElement { * @returns { void } */ extractHeaders() { - const headerRow = this.shadowRoot.querySelector('thead tr'); + if (this.columnHeaders) { + const headerRow = this.shadowRoot.querySelector('thead tr'); - headerRow.innerHTML = ''; + headerRow.innerHTML = ''; - this.columnHeaders.forEach((header) => { - const th = document.createElement('th'); + this.columnHeaders.forEach((header) => { + const th = document.createElement('th'); - th.innerHTML = header; - headerRow.appendChild(th); - }); + th.innerHTML = header; + headerRow.appendChild(th); + }); + } } /** diff --git a/demo/index.min.js b/demo/index.min.js index 3bb0ea4..be265e8 100644 --- a/demo/index.min.js +++ b/demo/index.min.js @@ -71,16 +71,18 @@ class AuroTable extends LitElement { * @returns { void } */ extractHeaders() { - const headerRow = this.shadowRoot.querySelector('thead tr'); + if (this.columnHeaders) { + const headerRow = this.shadowRoot.querySelector('thead tr'); - headerRow.innerHTML = ''; + headerRow.innerHTML = ''; - this.columnHeaders.forEach((header) => { - const th = document.createElement('th'); + this.columnHeaders.forEach((header) => { + const th = document.createElement('th'); - th.innerHTML = header; - headerRow.appendChild(th); - }); + th.innerHTML = header; + headerRow.appendChild(th); + }); + } } /** diff --git a/src/auro-table.js b/src/auro-table.js index 620136e..003791f 100644 --- a/src/auro-table.js +++ b/src/auro-table.js @@ -72,16 +72,18 @@ export class AuroTable extends LitElement { * @returns { void } */ extractHeaders() { - const headerRow = this.shadowRoot.querySelector('thead tr'); + if (this.columnHeaders) { + const headerRow = this.shadowRoot.querySelector('thead tr'); - headerRow.innerHTML = ''; + headerRow.innerHTML = ''; - this.columnHeaders.forEach((header) => { - const th = document.createElement('th'); + this.columnHeaders.forEach((header) => { + const th = document.createElement('th'); - th.innerHTML = header; - headerRow.appendChild(th); - }); + th.innerHTML = header; + headerRow.appendChild(th); + }); + } } /**