]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: fix DropdownMenu body handler check to ignore the element itself 11465/head
authorNicolas Coden <nicolas@ncoden.fr>
Mon, 20 Aug 2018 20:54:18 +0000 (22:54 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Mon, 20 Aug 2018 20:54:18 +0000 (22:54 +0200)
> `andSelf()` is deprecated and should be replaced with `addBack()`
> -- @SassNinja

Also, `andSelf` cannot be used that way. This commit replace it with the opposite approach: checking if the target is the child of the element or the element itself using `closest()`.

js/foundation.dropdownMenu.js

index 338cf5c9f3791ce58e9e6725bb378e652b812693..b2aed651b80b9f9b08b2123f09f4d18377047418 100644 (file)
@@ -284,7 +284,7 @@ class DropdownMenu extends Plugin {
     const $body = $(document.body);
     this._removeBodyHandler();
     $body.on('click.zf.dropdownMenu tap.zf.dropdownMenu', (e) => {
-      var isItself = this.$element.andSelf().find(e.target).length;
+      var isItself = !!$(e.target).closest(this.$element).length;
       if (isItself) return;
 
       this._hide();