From f85d7077ceac0296a8e14b4847f5ced0617dc67c Mon Sep 17 00:00:00 2001 From: zhixin Date: Sat, 14 Dec 2024 19:44:55 +0800 Subject: [PATCH 1/2] Fixed insertRow bug after on last row of table --- src/bootstrap-table.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap-table.js b/src/bootstrap-table.js index 39e2339f4..ccc8714af 100644 --- a/src/bootstrap-table.js +++ b/src/bootstrap-table.js @@ -2587,6 +2587,11 @@ class BootstrapTable { const row = this.data[params.index] const originalIndex = this.options.data.indexOf(row) + if (originalIndex === -1) { + this.append([params.row]) + return + } + this.data.splice(params.index, 0, params.row) this.options.data.splice(originalIndex, 0, params.row) this.initSearch() From 14538297fa01d3957f2c3e0bcb6c8f3a50e5b538 Mon Sep 17 00:00:00 2001 From: zhixin Date: Wed, 18 Dec 2024 15:18:18 +0800 Subject: [PATCH 2/2] Optimize the implementation of the getBootstrapVersion method --- src/utils/index.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index e7c6ff8ce..5a7752597 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -2,27 +2,20 @@ export default { getBootstrapVersion () { let bootstrapVersion = 5 - try { - const rawVersion = $.fn.dropdown.Constructor.VERSION + if (typeof window !== 'undefined' && window.bootstrap?.Tooltip?.VERSION) { + const rawVersion = window.bootstrap.Tooltip.VERSION - // Only try to parse VERSION if it is defined. - // It is undefined in older versions of Bootstrap (tested with 3.1.1). if (rawVersion !== undefined) { bootstrapVersion = parseInt(rawVersion, 10) } - } catch (e) { - console.error(e) - } - - try { - // eslint-disable-next-line no-undef - const rawVersion = bootstrap.Tooltip.VERSION + } else if (typeof $ !== 'undefined' && $.fn?.dropdown?.Constructor?.VERSION) { + const rawVersion = $.fn.dropdown.Constructor.VERSION + // Only try to parse VERSION if it is defined. + // It is undefined in older versions of Bootstrap (tested with 3.1.1). if (rawVersion !== undefined) { bootstrapVersion = parseInt(rawVersion, 10) } - } catch (e) { - console.error(e) } return bootstrapVersion