mixpanel-js-utils
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -1,165 +0,108 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
var hasOwnHandler = function (element) { | ||
var tests = [ | ||
function (node) { | ||
return ['form', 'input', 'select', 'textarea', 'submit', 'a'].indexOf(node.tagName.toLowerCase()) !== -1; | ||
}, | ||
function (node) { | ||
// for onclick properties and attributes | ||
return node.onclick || node.getAttribute('onclick'); | ||
}, | ||
function (node) { | ||
return !!(jQuery._data || jQuery.data)(node, 'events') | ||
}, | ||
function (node) { | ||
// jquery 1.3.x and 1.4x | ||
return !!node.getAttributes('data-events'); | ||
}, | ||
function (node) { | ||
// jquery 1.5.x | ||
for(var i = 0; i < Event.observers.length; i++) { | ||
var observer = Event.observers[i]; | ||
if ((observer || [])[0] === node) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}, | ||
function (node) { | ||
// jquery 1.6 to 1.6.0.3 | ||
return Event.cache[node._eventId || node._prototypeEventID[0]].click[0]; | ||
} | ||
]; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
for (var i = 0; i < tests.length; i++) { | ||
var test = tests[i]; | ||
try { | ||
if (test(element)) { | ||
return true; | ||
} | ||
} catch (e) {} | ||
} | ||
return false; | ||
}; | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
var nearestInteractiveElement = function(element, cache) { | ||
if (cache && cache[element] && cache[element].element === element) { | ||
return cache[element].closest; | ||
} | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
if (['html', 'head'].indexOf(element.tagName.toLowerCase()) > -1) { // can't call css on these | ||
return null; | ||
} | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
// next, try to find the closest element with a click handler | ||
var child, closest; | ||
var visited_candidates = []; | ||
for (var candidate = element; | ||
!closest && candidate && !(candidate.tagName.toLowerCase() === 'body'); | ||
child = candidate, candidate = candidate.parentElement) { | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
visited_candidates.push(candidate); | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
// skip candidates that don't accept pointer events | ||
if (candidate.style['pointer-events'] === 'none') { | ||
continue; | ||
} | ||
// if the cursor becomes default, assume that the child was clickable | ||
if (child) { | ||
var candidateStyles = window.getComputedStyle(candidate); | ||
var childStyles = window.getComputedStyle(child); | ||
var cursor = candidateStyles['cursor']; | ||
if ((cursor === 'default' || cursor === 'auto') && cursor !== childStyles['cursor']) { | ||
closest = child; | ||
break; | ||
} | ||
} | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
// if there are data- attributes we assume that it's used for something interactive | ||
var attrs = candidate.attributes; | ||
for(var i = 0; i < attrs.length; i++) { | ||
if (/^data\-/.test(attrs[i].name)) { | ||
closest = candidate; | ||
break; | ||
} | ||
} | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
// if the element has its own click handler, it is almost certainly clickable | ||
if (hasOwnHandler(candidate)) { | ||
closest = candidate; | ||
break; | ||
} | ||
} | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
if (cache && closest) { | ||
for (var i = 0; i < visited_candidates.length; i++) { | ||
var candidate = visited_candidates[i]; | ||
cache[candidate] = closest; | ||
}; | ||
cache[element] = { | ||
closest: closest, | ||
element: element | ||
}; | ||
} | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
return closest || element; | ||
}; | ||
"use strict"; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var nearestInteractiveElement = _interopRequire(__webpack_require__(1)); | ||
exports.nearestInteractiveElement = nearestInteractiveElement; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
var hasOwnHandler = function (element) { | ||
var tests = [function (node) { | ||
return ["form", "input", "select", "textarea", "submit", "a"].indexOf(node.tagName.toLowerCase()) !== -1; | ||
}, function (node) { | ||
// for onclick properties and attributes | ||
return node.onclick || node.getAttribute("onclick"); | ||
}, function (node) { | ||
return !!(jQuery._data || jQuery.data)(node, "events"); | ||
}, function (node) { | ||
// jquery 1.3.x and 1.4x | ||
return !!node.getAttributes("data-events"); | ||
}, function (node) { | ||
// jquery 1.5.x | ||
for (var i = 0; i < Event.observers.length; i++) { | ||
var observer = Event.observers[i]; | ||
if ((observer || [])[0] === node) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}, function (node) { | ||
// jquery 1.6 to 1.6.0.3 | ||
return Event.cache[node._eventId || node._prototypeEventID[0]].click[0]; | ||
}]; | ||
for (var i = 0; i < tests.length; i++) { | ||
var test = tests[i]; | ||
try { | ||
if (test(element)) { | ||
return true; | ||
} | ||
} catch (e) {} | ||
} | ||
return false; | ||
}; | ||
var nearestInteractiveElement = function (element, cache) { | ||
if (cache && cache[element] && cache[element].element === element) { | ||
return cache[element].closest; | ||
} | ||
if (["html", "head"].indexOf(element.tagName.toLowerCase()) > -1) { | ||
// can't call css on these | ||
return null; | ||
} | ||
// next, try to find the closest element with a click handler | ||
var child, closest; | ||
var visited_candidates = []; | ||
for (var candidate = element; !closest && candidate && !(candidate.tagName.toLowerCase() === "body"); child = candidate, candidate = candidate.parentElement) { | ||
visited_candidates.push(candidate); | ||
// skip candidates that don't accept pointer events | ||
if (candidate.style["pointer-events"] === "none") { | ||
continue; | ||
} | ||
// if the cursor becomes default, assume that the child was clickable | ||
if (child) { | ||
var candidateStyles = window.getComputedStyle(candidate); | ||
var childStyles = window.getComputedStyle(child); | ||
var cursor = candidateStyles.cursor; | ||
if ((cursor === "default" || cursor === "auto") && cursor !== childStyles.cursor) { | ||
closest = child; | ||
break; | ||
} | ||
} | ||
// if there are data- attributes we assume that it's used for something interactive | ||
var attrs = candidate.attributes; | ||
for (var i = 0; i < attrs.length; i++) { | ||
if (/^data\-/.test(attrs[i].name)) { | ||
closest = candidate; | ||
break; | ||
} | ||
} | ||
// if the element has its own click handler, it is almost certainly clickable | ||
if (hasOwnHandler(candidate)) { | ||
closest = candidate; | ||
break; | ||
} | ||
} | ||
if (cache && closest) { | ||
for (var i = 0; i < visited_candidates.length; i++) { | ||
var candidate = visited_candidates[i]; | ||
cache[candidate] = closest; | ||
}; | ||
cache[element] = { | ||
closest: closest, | ||
element: element | ||
}; | ||
} | ||
return closest || element; | ||
}; | ||
module.exports = nearestInteractiveElement; | ||
/***/ } | ||
/******/ ]); | ||
export { nearestInteractiveElement }; |
{ | ||
"name": "mixpanel-js-utils", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Javascript utilities for use across Mixpanel products", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
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
7776
201