carbon-components
Advanced tools
Comparing version 7.14.1 to 7.15.0
@@ -69,10 +69,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
value: function _getContainer() { | ||
var element = this.element; | ||
var body = element.ownerDocument.body; | ||
for (var traverse = element; traverse && traverse !== body; traverse = traverse.parentNode) { | ||
if (traverse.matches(this.options.selectorContainer)) { | ||
return traverse; | ||
} | ||
} | ||
return body; | ||
return this.element.closest(this.options.selectorContainer) || this.element.ownerDocument.body; | ||
} | ||
@@ -79,0 +72,0 @@ |
@@ -0,1 +1,7 @@ | ||
/** | ||
* @param {Event} event The event. | ||
* @param {string} selector The selector. | ||
* @returns {Element} | ||
* The closest ancestor of the event target (or the event target itself) which matches the selectors given in parameter. | ||
*/ | ||
export default function eventMatches(event, selector) { | ||
@@ -10,8 +16,5 @@ // <svg> in IE does not have `Element#msMatchesSelector()` (that should be copied to `Element#matches()` by a polyfill). | ||
} else if (event.target.matches(selector + ' *')) { | ||
// If event target is a child node of a DOM element that matches the given selector, | ||
// find the DOM element by going up the DOM tree | ||
for (var traverse = event.target; traverse && traverse !== event.currentTarget; traverse = traverse.parentNode) { | ||
if (traverse.matches(selector)) { | ||
return traverse; | ||
} | ||
var closest = event.target.closest(selector); | ||
if (event.currentTarget.contains(closest)) { | ||
return closest; | ||
} | ||
@@ -18,0 +21,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"homepage": "http://carbondesignsystem.com/", | ||
"version": "7.14.1", | ||
"version": "7.15.0", | ||
"module": "es/index.js", | ||
@@ -8,0 +8,0 @@ "main": "umd/index.js", |
@@ -49,10 +49,3 @@ import mixin from '../../globals/js/misc/mixin'; | ||
_getContainer() { | ||
const element = this.element; | ||
const body = element.ownerDocument.body; | ||
for (let traverse = element; traverse && traverse !== body; traverse = traverse.parentNode) { | ||
if (traverse.matches(this.options.selectorContainer)) { | ||
return traverse; | ||
} | ||
} | ||
return body; | ||
return this.element.closest(this.options.selectorContainer) || this.element.ownerDocument.body; | ||
} | ||
@@ -59,0 +52,0 @@ |
@@ -0,1 +1,7 @@ | ||
/** | ||
* @param {Event} event The event. | ||
* @param {string} selector The selector. | ||
* @returns {Element} | ||
* The closest ancestor of the event target (or the event target itself) which matches the selectors given in parameter. | ||
*/ | ||
export default function eventMatches(event, selector) { | ||
@@ -10,8 +16,5 @@ // <svg> in IE does not have `Element#msMatchesSelector()` (that should be copied to `Element#matches()` by a polyfill). | ||
} else if (event.target.matches(`${selector} *`)) { | ||
// If event target is a child node of a DOM element that matches the given selector, | ||
// find the DOM element by going up the DOM tree | ||
for (let traverse = event.target; traverse && traverse !== event.currentTarget; traverse = traverse.parentNode) { | ||
if (traverse.matches(selector)) { | ||
return traverse; | ||
} | ||
const closest = event.target.closest(selector); | ||
if (event.currentTarget.contains(closest)) { | ||
return closest; | ||
} | ||
@@ -18,0 +21,0 @@ } |
@@ -160,10 +160,3 @@ (function (global, factory) { | ||
value: function _getContainer() { | ||
var element = this.element; | ||
var body = element.ownerDocument.body; | ||
for (var traverse = element; traverse && traverse !== body; traverse = traverse.parentNode) { | ||
if (traverse.matches(this.options.selectorContainer)) { | ||
return traverse; | ||
} | ||
} | ||
return body; | ||
return this.element.closest(this.options.selectorContainer) || this.element.ownerDocument.body; | ||
} | ||
@@ -170,0 +163,0 @@ }, { |
@@ -20,2 +20,8 @@ (function (global, factory) { | ||
exports.default = eventMatches; | ||
/** | ||
* @param {Event} event The event. | ||
* @param {string} selector The selector. | ||
* @returns {Element} | ||
* The closest ancestor of the event target (or the event target itself) which matches the selectors given in parameter. | ||
*/ | ||
function eventMatches(event, selector) { | ||
@@ -30,8 +36,5 @@ // <svg> in IE does not have `Element#msMatchesSelector()` (that should be copied to `Element#matches()` by a polyfill). | ||
} else if (event.target.matches(selector + ' *')) { | ||
// If event target is a child node of a DOM element that matches the given selector, | ||
// find the DOM element by going up the DOM tree | ||
for (var traverse = event.target; traverse && traverse !== event.currentTarget; traverse = traverse.parentNode) { | ||
if (traverse.matches(selector)) { | ||
return traverse; | ||
} | ||
var closest = event.target.closest(selector); | ||
if (event.currentTarget.contains(closest)) { | ||
return closest; | ||
} | ||
@@ -38,0 +41,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3016923
32558