]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Merge pull request #10377 from hikouki/extend
authorKevin Ball <kmball11@gmail.com>
Tue, 11 Jul 2017 21:53:20 +0000 (14:53 -0700)
committerKevin Ball <kmball11@gmail.com>
Tue, 25 Jul 2017 00:08:21 +0000 (17:08 -0700)
Fixed: I made the option posible recursively merge.

js/foundation.abide.js
test/javascript/components/abide.js

index b1cea1e78957aeba0a208522b835d9c0ec3d2fc3..d6ad376962506222b67b9f66f52f539ec9804d13 100644 (file)
@@ -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();
index 13ae0e98b64bb0286207c010846eca982a7443b1..37f5c144a9ec2bcc9acb3f0339517fd474d14fcb 100644 (file)
@@ -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 = $('<form data-abide novalidate></form>').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() {