Skip to content

Commit

Permalink
Add an extra check for an e.target.className.indexOf function
Browse files Browse the repository at this point in the history
  • Loading branch information
soren121 committed Oct 18, 2019
1 parent ffcba2d commit 3637c19
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/vendor/detectElementResize.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export default function createDetectElementResize(nonce) {
var scrollListener = function(e) {
// Don't measure (which forces) reflow for scrolls that happen inside of children!
if (
e.target.className &&
typeof e.target.className.indexOf === 'function' &&
e.target.className.indexOf('contract-trigger') < 0 &&
e.target.className.indexOf('expand-trigger') < 0
) {
Expand Down Expand Up @@ -99,7 +101,7 @@ export default function createDetectElementResize(nonce) {
animationstartevent = 'animationstart',
domPrefixes = 'Webkit Moz O ms'.split(' '),
startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(
' ',
' '
),
pfx = '';
{
Expand Down Expand Up @@ -186,15 +188,15 @@ export default function createDetectElementResize(nonce) {
/* Listen for a css animation to detect element display/re-attach */
if (animationstartevent) {
element.__resizeTriggers__.__animationListener__ = function animationListener(
e,
e
) {
if (e.animationName == animationName) {
resetTriggers(element);
}
};
element.__resizeTriggers__.addEventListener(
animationstartevent,
element.__resizeTriggers__.__animationListener__,
element.__resizeTriggers__.__animationListener__
);
}
}
Expand All @@ -208,20 +210,20 @@ export default function createDetectElementResize(nonce) {
} else {
element.__resizeListeners__.splice(
element.__resizeListeners__.indexOf(fn),
1,
1
);
if (!element.__resizeListeners__.length) {
element.removeEventListener('scroll', scrollListener, true);
if (element.__resizeTriggers__.__animationListener__) {
element.__resizeTriggers__.removeEventListener(
animationstartevent,
element.__resizeTriggers__.__animationListener__,
element.__resizeTriggers__.__animationListener__
);
element.__resizeTriggers__.__animationListener__ = null;
}
try {
element.__resizeTriggers__ = !element.removeChild(
element.__resizeTriggers__,
element.__resizeTriggers__
);
} catch (e) {
// Preact compat; see developit/preact-compat/issues/228
Expand Down

0 comments on commit 3637c19

Please sign in to comment.