From 16d80a4ff7b42da57215783cc8ff85d6f0627630 Mon Sep 17 00:00:00 2001 From: Nathan Sarang-Walters Date: Thu, 18 Jul 2024 22:05:21 -0700 Subject: Fix `this` reference for JavaScript functions (#38725) --- js/src/dropdown.js | 2 +- js/src/tooltip.js | 4 ++-- js/src/util/index.js | 2 +- js/src/util/template-factory.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'js/src') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 9190b3ed5..96094a3e6 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -320,7 +320,7 @@ class Dropdown extends BaseComponent { return { ...defaultBsPopperConfig, - ...execute(this._config.popperConfig, [defaultBsPopperConfig]) + ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig]) } } diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 6a6cfeff2..92d455349 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -392,7 +392,7 @@ class Tooltip extends BaseComponent { } _resolvePossibleFunction(arg) { - return execute(arg, [this._element]) + return execute(arg, [this._element, this._element]) } _getPopperConfig(attachment) { @@ -438,7 +438,7 @@ class Tooltip extends BaseComponent { return { ...defaultBsPopperConfig, - ...execute(this._config.popperConfig, [defaultBsPopperConfig]) + ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig]) } } diff --git a/js/src/util/index.js b/js/src/util/index.js index 2adf19e3b..c271cc536 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -223,7 +223,7 @@ const defineJQueryPlugin = plugin => { } const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => { - return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue + return typeof possibleCallback === 'function' ? possibleCallback.call(...args) : defaultValue } const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => { diff --git a/js/src/util/template-factory.js b/js/src/util/template-factory.js index f73589bcc..6d1532b4d 100644 --- a/js/src/util/template-factory.js +++ b/js/src/util/template-factory.js @@ -143,7 +143,7 @@ class TemplateFactory extends Config { } _resolvePossibleFunction(arg) { - return execute(arg, [this]) + return execute(arg, [undefined, this]) } _putElementInTemplate(element, templateElement) { -- cgit v1.2.3