Skip to content

Commit 762bc13

Browse files
Replaced "findAncestor()" method with native "closest()" joomla-projects#121
1 parent acc7318 commit 762bc13

9 files changed

+26
-26
lines changed

dist/js/joomla-dropdown-es5.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
88
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
99
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); }
1010
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); }
11-
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; } }
11+
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; } }
1212
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
1313
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
1414
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) {
5252
}
5353
document.addEventListener('click', function (evt) {
5454
if (evt.target !== button) {
55-
if (!_this.findAncestor(evt.target, 'joomla-dropdown')) {
55+
if (!_this.closest(evt.target, 'joomla-dropdown')) {
5656
_this.close();
5757
}
5858
}
@@ -77,10 +77,10 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) {
7777
}
7878
}, {
7979
key: "adoptedCallback",
80-
value: function adoptedCallback(oldDocument, newDocument) {}
80+
value: function adoptedCallback(oldDocument, newDocument) { }
8181
}, {
8282
key: "attributeChangedCallback",
83-
value: function attributeChangedCallback(attr, oldValue, newValue) {}
83+
value: function attributeChangedCallback(attr, oldValue, newValue) { }
8484
/* eslint-enable */
8585
}, {
8686
key: "close",
@@ -93,7 +93,7 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) {
9393
/* eslint-disable */
9494
}, {
9595
key: "findAncestor",
96-
value: function findAncestor(el, tagName) {
96+
value: function closest(el, tagName) {
9797
while ((el = el.parentElement) && el.nodeName.toLowerCase() !== tagName) {
9898
;
9999
}
@@ -103,9 +103,9 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) {
103103
}], [{
104104
key: "observedAttributes",
105105
get: /* Attributes to monitor */
106-
function get() {
107-
return ['for'];
108-
}
106+
function get() {
107+
return ['for'];
108+
}
109109
}]);
110110
return JoomlaDropdownElement;
111111
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));

dist/js/joomla-dropdown-es5.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/joomla-dropdown.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class JoomlaDropdownElement extends HTMLElement {
3333

3434
document.addEventListener('click', (evt) => {
3535
if (evt.target !== button) {
36-
if (!this.findAncestor(evt.target, 'joomla-dropdown')) {
36+
if (!this.closest(evt.target, 'joomla-dropdown')) {
3737
this.close();
3838
}
3939
}
@@ -70,7 +70,7 @@ class JoomlaDropdownElement extends HTMLElement {
7070
}
7171

7272
/* eslint-disable */
73-
findAncestor(el, tagName) {
73+
closest(el, tagName) {
7474
while ((el = el.parentElement) && el.nodeName.toLowerCase() !== tagName);
7575
return el;
7676
}

dist/js/joomla-dropdown.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/_media/js/joomla-dropdown-es5.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
88
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
99
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); }
1010
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); }
11-
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; } }
11+
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; } }
1212
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
1313
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
1414
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) {
5252
}
5353
document.addEventListener('click', function (evt) {
5454
if (evt.target !== button) {
55-
if (!_this.findAncestor(evt.target, 'joomla-dropdown')) {
55+
if (!_this.closest(evt.target, 'joomla-dropdown')) {
5656
_this.close();
5757
}
5858
}
@@ -77,10 +77,10 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) {
7777
}
7878
}, {
7979
key: "adoptedCallback",
80-
value: function adoptedCallback(oldDocument, newDocument) {}
80+
value: function adoptedCallback(oldDocument, newDocument) { }
8181
}, {
8282
key: "attributeChangedCallback",
83-
value: function attributeChangedCallback(attr, oldValue, newValue) {}
83+
value: function attributeChangedCallback(attr, oldValue, newValue) { }
8484
/* eslint-enable */
8585
}, {
8686
key: "close",
@@ -93,7 +93,7 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) {
9393
/* eslint-disable */
9494
}, {
9595
key: "findAncestor",
96-
value: function findAncestor(el, tagName) {
96+
value: function closest(el, tagName) {
9797
while ((el = el.parentElement) && el.nodeName.toLowerCase() !== tagName) {
9898
;
9999
}
@@ -103,9 +103,9 @@ var JoomlaDropdownElement = /*#__PURE__*/function (_HTMLElement) {
103103
}], [{
104104
key: "observedAttributes",
105105
get: /* Attributes to monitor */
106-
function get() {
107-
return ['for'];
108-
}
106+
function get() {
107+
return ['for'];
108+
}
109109
}]);
110110
return JoomlaDropdownElement;
111111
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));

0 commit comments

Comments
 (0)