From: koki-higashikawa Date: Sat, 8 Jul 2017 22:39:58 +0000 (+0900) Subject: Option be able to recursively merged. X-Git-Tag: v6.4.2-rc2~1^2~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F10377%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Option be able to recursively merged. --- diff --git a/js/foundation.abide.js b/js/foundation.abide.js index b1cea1e78..d6ad37696 100644 --- a/js/foundation.abide.js +++ b/js/foundation.abide.js @@ -19,7 +19,7 @@ class Abide extends Plugin { */ _setup(element, options = {}) { this.$element = element; - this.options = $.extend({}, Abide.defaults, this.$element.data(), options); + this.options = $.extend(true, {}, Abide.defaults, this.$element.data(), options); this.className = 'Abide'; // ie9 back compat this._init(); diff --git a/test/javascript/components/abide.js b/test/javascript/components/abide.js index 13ae0e98b..37f5c144a 100644 --- a/test/javascript/components/abide.js +++ b/test/javascript/components/abide.js @@ -18,6 +18,22 @@ describe('Abide', function() { plugin.$element.should.be.an('object'); plugin.options.should.be.an('object'); }); + + it('the options are recursively merged', function() { + $html = $('
').appendTo('body'); + + var options = { + validators: { + notEqualTo: function (el, required, parent) { + return $(`#${el.attr('data-equalto')}`).val() !== el.val(); + } + } + }; + + plugin = new Foundation.Abide($html, options); + + plugin.options.validators.should.includes.keys('equalTo', 'notEqualTo'); + }); }); describe('validateInput()', function() {