diff --git a/dist/js/joomla-dropdown-es5.js b/dist/js/joomla-dropdown-es5.js index 13aaa19..8778590 100644 --- a/dist/js/joomla-dropdown-es5.js +++ b/dist/js/joomla-dropdown-es5.js @@ -8,7 +8,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () { })); return true; } catch (e) { return false; } } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } @@ -52,7 +52,7 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) { } document.addEventListener('click', function (evt) { if (evt.target !== button) { - if (!_this.findAncestor(evt.target, 'joomla-dropdown')) { + if (!_this.closest(evt.target, 'joomla-dropdown')) { _this.close(); } } @@ -77,10 +77,10 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) { } }, { key: "adoptedCallback", - value: function adoptedCallback(oldDocument, newDocument) {} + value: function adoptedCallback(oldDocument, newDocument) { } }, { key: "attributeChangedCallback", - value: function attributeChangedCallback(attr, oldValue, newValue) {} + value: function attributeChangedCallback(attr, oldValue, newValue) { } /* eslint-enable */ }, { key: "close", @@ -93,7 +93,7 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) { /* eslint-disable */ }, { key: "findAncestor", - value: function findAncestor(el, tagName) { + value: function closest(el, tagName) { while ((el = el.parentElement) && el.nodeName.toLowerCase() !== tagName) { ; } @@ -103,9 +103,9 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) { }], [{ key: "observedAttributes", get: /* Attributes to monitor */ - function get() { - return ['for']; - } + function get() { + return ['for']; + } }]); return JoomlaDropdownElement; }( /*#__PURE__*/_wrapNativeSuper(HTMLElement)); diff --git a/dist/js/joomla-dropdown-es5.min.js b/dist/js/joomla-dropdown-es5.min.js index 6b97deb..f256fac 100644 --- a/dist/js/joomla-dropdown-es5.min.js +++ b/dist/js/joomla-dropdown-es5.min.js @@ -1 +1 @@ -function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n { if (evt.target !== button) { - if (!this.findAncestor(evt.target, 'joomla-dropdown')) { + if (!this.closest(evt.target, 'joomla-dropdown')) { this.close(); } } @@ -70,7 +70,7 @@ class JoomlaDropdownElement extends HTMLElement { } /* eslint-disable */ - findAncestor(el, tagName) { + closest(el, tagName) { while ((el = el.parentElement) && el.nodeName.toLowerCase() !== tagName); return el; } diff --git a/dist/js/joomla-dropdown.min.js b/dist/js/joomla-dropdown.min.js index 51a7972..b3e2e11 100644 --- a/dist/js/joomla-dropdown.min.js +++ b/dist/js/joomla-dropdown.min.js @@ -1 +1 @@ -class t extends HTMLElement{static get observedAttributes(){return["for"]}get for(){return this.getAttribute("for")}set for(t){this.setAttribute("for",t)}connectedCallback(){this.setAttribute("aria-labelledby",this.for.substring(1));const t=document.querySelector(this.for),e=this.querySelectorAll("a");t.id&&(t.setAttribute("aria-haspopup",!0),t.setAttribute("aria-expanded",!1),t.addEventListener("click",(r=>{this.hasAttribute("expanded")?(this.removeAttribute("expanded"),r.target.setAttribute("aria-expanded",!1)):(this.setAttribute("expanded",""),r.target.setAttribute("aria-expanded",!0)),document.addEventListener("click",(e=>{e.target!==t&&(this.findAncestor(e.target,"joomla-dropdown")||this.close())})),e.forEach((t=>{t.addEventListener("click",(()=>{this.close()}))}))})))}dispatchCustomEvent(t){const e=new CustomEvent(t);e.relatedTarget=this,this.dispatchEvent(e),this.removeEventListener(t,this)}adoptedCallback(t,e){}attributeChangedCallback(t,e,r){}close(){const t=document.querySelector(`#${this.getAttribute("aria-labelledby")}`);this.removeAttribute("expanded"),t.setAttribute("aria-expanded",!1)}findAncestor(t,e){for(;(t=t.parentElement)&&t.nodeName.toLowerCase()!==e;);return t}}customElements.define("joomla-dropdown",t); +class t extends HTMLElement { static get observedAttributes() { return ["for"] } get for() { return this.getAttribute("for") } set for(t) { this.setAttribute("for", t) } connectedCallback() { this.setAttribute("aria-labelledby", this.for.substring(1)); const t = document.querySelector(this.for), e = this.querySelectorAll("a"); t.id && (t.setAttribute("aria-haspopup", !0), t.setAttribute("aria-expanded", !1), t.addEventListener("click", (r => { this.hasAttribute("expanded") ? (this.removeAttribute("expanded"), r.target.setAttribute("aria-expanded", !1)) : (this.setAttribute("expanded", ""), r.target.setAttribute("aria-expanded", !0)), document.addEventListener("click", (e => { e.target !== t && (this.closest(e.target, "joomla-dropdown") || this.close()) })), e.forEach((t => { t.addEventListener("click", (() => { this.close() })) })) }))) } dispatchCustomEvent(t) { const e = new CustomEvent(t); e.relatedTarget = this, this.dispatchEvent(e), this.removeEventListener(t, this) } adoptedCallback(t, e) { } attributeChangedCallback(t, e, r) { } close() { const t = document.querySelector(`#${this.getAttribute("aria-labelledby")}`); this.removeAttribute("expanded"), t.setAttribute("aria-expanded", !1) } closest(t, e) { for (; (t = t.parentElement) && t.nodeName.toLowerCase() !== e;); return t } } customElements.define("joomla-dropdown", t); diff --git a/docs/_media/js/joomla-dropdown-es5.js b/docs/_media/js/joomla-dropdown-es5.js index 13aaa19..8778590 100644 --- a/docs/_media/js/joomla-dropdown-es5.js +++ b/docs/_media/js/joomla-dropdown-es5.js @@ -8,7 +8,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () { })); return true; } catch (e) { return false; } } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } @@ -52,7 +52,7 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) { } document.addEventListener('click', function (evt) { if (evt.target !== button) { - if (!_this.findAncestor(evt.target, 'joomla-dropdown')) { + if (!_this.closest(evt.target, 'joomla-dropdown')) { _this.close(); } } @@ -77,10 +77,10 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) { } }, { key: "adoptedCallback", - value: function adoptedCallback(oldDocument, newDocument) {} + value: function adoptedCallback(oldDocument, newDocument) { } }, { key: "attributeChangedCallback", - value: function attributeChangedCallback(attr, oldValue, newValue) {} + value: function attributeChangedCallback(attr, oldValue, newValue) { } /* eslint-enable */ }, { key: "close", @@ -93,7 +93,7 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) { /* eslint-disable */ }, { key: "findAncestor", - value: function findAncestor(el, tagName) { + value: function closest(el, tagName) { while ((el = el.parentElement) && el.nodeName.toLowerCase() !== tagName) { ; } @@ -103,9 +103,9 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) { }], [{ key: "observedAttributes", get: /* Attributes to monitor */ - function get() { - return ['for']; - } + function get() { + return ['for']; + } }]); return JoomlaDropdownElement; }( /*#__PURE__*/_wrapNativeSuper(HTMLElement)); diff --git a/docs/_media/js/joomla-dropdown-es5.min.js b/docs/_media/js/joomla-dropdown-es5.min.js index 6b97deb..f256fac 100644 --- a/docs/_media/js/joomla-dropdown-es5.min.js +++ b/docs/_media/js/joomla-dropdown-es5.min.js @@ -1 +1 @@ -function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n { if (evt.target !== button) { - if (!this.findAncestor(evt.target, 'joomla-dropdown')) { + if (!this.closest(evt.target, 'joomla-dropdown')) { this.close(); } } @@ -70,7 +70,7 @@ class JoomlaDropdownElement extends HTMLElement { } /* eslint-disable */ - findAncestor(el, tagName) { + closest(el, tagName) { while ((el = el.parentElement) && el.nodeName.toLowerCase() !== tagName); return el; } diff --git a/docs/_media/js/joomla-dropdown.min.js b/docs/_media/js/joomla-dropdown.min.js index 51a7972..b3e2e11 100644 --- a/docs/_media/js/joomla-dropdown.min.js +++ b/docs/_media/js/joomla-dropdown.min.js @@ -1 +1 @@ -class t extends HTMLElement{static get observedAttributes(){return["for"]}get for(){return this.getAttribute("for")}set for(t){this.setAttribute("for",t)}connectedCallback(){this.setAttribute("aria-labelledby",this.for.substring(1));const t=document.querySelector(this.for),e=this.querySelectorAll("a");t.id&&(t.setAttribute("aria-haspopup",!0),t.setAttribute("aria-expanded",!1),t.addEventListener("click",(r=>{this.hasAttribute("expanded")?(this.removeAttribute("expanded"),r.target.setAttribute("aria-expanded",!1)):(this.setAttribute("expanded",""),r.target.setAttribute("aria-expanded",!0)),document.addEventListener("click",(e=>{e.target!==t&&(this.findAncestor(e.target,"joomla-dropdown")||this.close())})),e.forEach((t=>{t.addEventListener("click",(()=>{this.close()}))}))})))}dispatchCustomEvent(t){const e=new CustomEvent(t);e.relatedTarget=this,this.dispatchEvent(e),this.removeEventListener(t,this)}adoptedCallback(t,e){}attributeChangedCallback(t,e,r){}close(){const t=document.querySelector(`#${this.getAttribute("aria-labelledby")}`);this.removeAttribute("expanded"),t.setAttribute("aria-expanded",!1)}findAncestor(t,e){for(;(t=t.parentElement)&&t.nodeName.toLowerCase()!==e;);return t}}customElements.define("joomla-dropdown",t); +class t extends HTMLElement { static get observedAttributes() { return ["for"] } get for() { return this.getAttribute("for") } set for(t) { this.setAttribute("for", t) } connectedCallback() { this.setAttribute("aria-labelledby", this.for.substring(1)); const t = document.querySelector(this.for), e = this.querySelectorAll("a"); t.id && (t.setAttribute("aria-haspopup", !0), t.setAttribute("aria-expanded", !1), t.addEventListener("click", (r => { this.hasAttribute("expanded") ? (this.removeAttribute("expanded"), r.target.setAttribute("aria-expanded", !1)) : (this.setAttribute("expanded", ""), r.target.setAttribute("aria-expanded", !0)), document.addEventListener("click", (e => { e.target !== t && (this.closest(e.target, "joomla-dropdown") || this.close()) })), e.forEach((t => { t.addEventListener("click", (() => { this.close() })) })) }))) } dispatchCustomEvent(t) { const e = new CustomEvent(t); e.relatedTarget = this, this.dispatchEvent(e), this.removeEventListener(t, this) } adoptedCallback(t, e) { } attributeChangedCallback(t, e, r) { } close() { const t = document.querySelector(`#${this.getAttribute("aria-labelledby")}`); this.removeAttribute("expanded"), t.setAttribute("aria-expanded", !1) } closest(t, e) { for (; (t = t.parentElement) && t.nodeName.toLowerCase() !== e;); return t } } customElements.define("joomla-dropdown", t); diff --git a/src/js/dropdown/dropdown.js b/src/js/dropdown/dropdown.js index aca8584..f51e37c 100644 --- a/src/js/dropdown/dropdown.js +++ b/src/js/dropdown/dropdown.js @@ -33,7 +33,7 @@ class JoomlaDropdownElement extends HTMLElement { document.addEventListener('click', (evt) => { if (evt.target !== button) { - if (!this.findAncestor(evt.target, 'joomla-dropdown')) { + if (!this.closest(evt.target, 'joomla-dropdown')) { this.close(); } } @@ -75,7 +75,7 @@ class JoomlaDropdownElement extends HTMLElement { } /* eslint-disable */ - findAncestor(el, tagName) { + closest(el, tagName) { while ((el = el.parentElement) && el.nodeName.toLowerCase() !== tagName); return el; }