From 630cf4ccb80c839a5983fdba901434a9ff427d6c Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Sat, 17 Feb 2018 23:58:39 +0100 Subject: [PATCH] fix: make Toggler target an option #10892 Related to: https://github.com/zurb/foundation-sites/issues/10892 --- js/foundation.toggler.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/foundation.toggler.js b/js/foundation.toggler.js index d8c5744ec..796099863 100644 --- a/js/foundation.toggler.js +++ b/js/foundation.toggler.js @@ -50,7 +50,10 @@ class Toggler extends Plugin { } // Otherwise, parse toggle class else { - input = this.$element.data('toggler'); + input = this.options.toggler; + if (typeof input !== 'string' || !input.length) { + throw new Error(`The 'toogler' option containing the target class is required, got "${input}"`); + } // Allow for a . at the beginning of the string this.className = input[0] === '.' ? input.slice(1) : input; } @@ -138,6 +141,12 @@ class Toggler extends Plugin { } Toggler.defaults = { + /** + * Class of the element to toggle. It can be provided with or without "." + * @option + * @type {string} + */ + toggler: undefined, /** * Tells the plugin if the element should animated when toggled. * @option -- 2.47.2