Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced "findAncestor()" method with native "closest()" #121 #225

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dist/js/joomla-dropdown-es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -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",
Expand All @@ -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) {
;
}
Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion dist/js/joomla-dropdown-es5.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/js/joomla-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/js/joomla-dropdown.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions docs/_media/js/joomla-dropdown-es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -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",
Expand All @@ -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) {
;
}
Expand All @@ -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));
Expand Down
Loading