From 21a65f181eebc3f2c0cd43fb3383ee3de673745b Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 16 Sep 2015 10:35:29 +0200 Subject: Add throw error for undefined method on plugins --- js/src/carousel.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'js/src/carousel.js') 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() -- cgit v1.2.3