diff options
| author | Chris Rebert <[email protected]> | 2015-10-02 01:18:16 -0700 |
|---|---|---|
| committer | Chris Rebert <[email protected]> | 2015-10-02 01:18:16 -0700 |
| commit | 10f6e97ec2c59cbeb3c892936e8b7cb3faa1e247 (patch) | |
| tree | deb94d828c341c1cfe61cf0435bb2f2d21836a21 /js/src | |
| parent | a89bfc65252f648469e84242289b8a45a49d08e9 (diff) | |
| parent | 21a65f181eebc3f2c0cd43fb3383ee3de673745b (diff) | |
| download | bootstrap-10f6e97ec2c59cbeb3c892936e8b7cb3faa1e247.tar.xz bootstrap-10f6e97ec2c59cbeb3c892936e8b7cb3faa1e247.zip | |
Merge pull request #17616 from Johann-S/ThrowError
Fix #17612: Throw explicit error when a nonexistent method is invoked
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/carousel.js | 7 | ||||
| -rw-r--r-- | js/src/collapse.js | 3 | ||||
| -rw-r--r-- | js/src/dropdown.js | 3 | ||||
| -rw-r--r-- | js/src/modal.js | 4 | ||||
| -rw-r--r-- | js/src/popover.js | 3 | ||||
| -rw-r--r-- | js/src/scrollspy.js | 3 | ||||
| -rw-r--r-- | js/src/tab.js | 3 | ||||
| -rw-r--r-- | js/src/tooltip.js | 3 |
8 files changed, 25 insertions, 4 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js index efacd9494..d8da854a2 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -390,10 +390,11 @@ const Carousel = (($) => { if (typeof config === 'number') { data.to(config) - - } else if (action) { + } else if (typeof action === 'string') { + if (data[action] === undefined) { + throw new Error(`No method named "${action}"`) + } data[action]() - } else if (_config.interval) { data.pause() data.cycle() diff --git a/js/src/collapse.js b/js/src/collapse.js index e46d3ec60..a9980926e 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -333,6 +333,9 @@ const Collapse = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 734e64312..f947d2aa1 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -143,6 +143,9 @@ const Dropdown = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config].call(this) } }) diff --git a/js/src/modal.js b/js/src/modal.js index f57131e7e..99a49f148 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -463,8 +463,10 @@ const Modal = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config](relatedTarget) - } else if (_config.show) { data.show(relatedTarget) } diff --git a/js/src/popover.js b/js/src/popover.js index b8b24a1c4..11ee86e70 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -153,6 +153,9 @@ const Popover = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 27a91958e..bdbd6439c 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -277,6 +277,9 @@ const ScrollSpy = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) diff --git a/js/src/tab.js b/js/src/tab.js index 4b311c24e..1283881e4 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -234,6 +234,9 @@ const Tab = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 151cd6f51..b80bd8e8c 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -622,6 +622,9 @@ const Tooltip = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) |
