Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

makeup-exit-emitter

Package Overview
Dependencies
Maintainers
7
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

makeup-exit-emitter - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

package-lock.json

50

dist/cjs/index.js

@@ -8,15 +8,5 @@ "use strict";

exports.removeFocusExit = removeFocusExit;
var _makeupNextId = _interopRequireDefault(require("makeup-next-id"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
var focusExitEmitters = {};
function doFocusExit(el, fromElement, toElement) {

@@ -29,3 +19,2 @@ el.dispatchEvent(new CustomEvent('focusExit', {

bubbles: false // mirror the native mouseleave event
}));

@@ -36,4 +25,5 @@ }

var newFocusElement = e.target;
var targetIsDescendant = this.el.contains(newFocusElement); // if focus has moved to a focusable descendant
var targetIsDescendant = this.el.contains(newFocusElement);
// if focus has moved to a focusable descendant
if (targetIsDescendant === true) {

@@ -50,19 +40,14 @@ // set the target as the currently focussed element

}
function onWindowBlur() {
doFocusExit(this.el, this.currentFocusElement, undefined);
}
function onWidgetFocusIn() {
// listen for focus moving to anywhere in document
// note that mouse click on buttons, checkboxes and radios does not trigger focus events in all browsers!
document.addEventListener('focusin', this.onDocumentFocusInListener); // listen for focus leaving the window
document.addEventListener('focusin', this.onDocumentFocusInListener);
// listen for focus leaving the window
window.addEventListener('blur', this.onWindowBlurListener);
}
var FocusExitEmitter = /*#__PURE__*/function () {
function FocusExitEmitter(el) {
_classCallCheck(this, FocusExitEmitter);
class FocusExitEmitter {
constructor(el) {
this.el = el;

@@ -75,19 +60,11 @@ this.currentFocusElement = null;

}
_createClass(FocusExitEmitter, [{
key: "removeEventListeners",
value: function removeEventListeners() {
window.removeEventListener('blur', this.onWindowBlurListener);
document.removeEventListener('focusin', this.onDocumentFocusInListener);
this.el.removeEventListener('focusin', this.onWidgetFocusInListener);
}
}]);
return FocusExitEmitter;
}();
removeEventListeners() {
window.removeEventListener('blur', this.onWindowBlurListener);
document.removeEventListener('focusin', this.onDocumentFocusInListener);
this.el.removeEventListener('focusin', this.onWidgetFocusInListener);
}
}
function addFocusExit(el) {
var exitEmitter = null;
(0, _makeupNextId.default)(el);
if (!focusExitEmitters[el.id]) {

@@ -97,9 +74,6 @@ exitEmitter = new FocusExitEmitter(el);

}
return exitEmitter;
}
function removeFocusExit(el) {
var exitEmitter = focusExitEmitters[el.id];
if (exitEmitter) {

@@ -106,0 +80,0 @@ exitEmitter.removeEventListeners();

{
"name": "makeup-exit-emitter",
"description": "Emits custom 'focusExit' event when keyboard focus has exited an element and all of it's descendants",
"version": "0.4.0",
"version": "0.4.1",
"main": "./dist/cjs/index.js",

@@ -6,0 +6,0 @@ "module": "./dist/mjs/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc