From e0ebb0ea49c4c86dab1ee45fe44856269c1dd762 Mon Sep 17 00:00:00 2001 From: koki-higashikawa Date: Sun, 9 Jul 2017 07:39:58 +0900 Subject: [PATCH] Option be able to recursively merged. --- js/foundation.abide.js | 2 +- test/javascript/components/abide.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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() { -- 2.47.2