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

@enact/core

Package Overview
Dependencies
Maintainers
1
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enact/core - npm Package Compare versions

Comparing version 2.0.0-beta.1 to 2.0.0-beta.2

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # Change Log

## [2.0.0-beta.2] - 2018-05-07
### Fixed
- `core/dispatcher.on` to not add duplicate event handlers
## [2.0.0-beta.1] - 2018-04-29

@@ -7,0 +13,0 @@

13

dispatcher/dispatcher.js

@@ -10,3 +10,3 @@ "use strict";

var _listeners = _interopRequireDefault(require("./listeners"));
var _listeners = require("./listeners");

@@ -65,3 +65,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var name = ev.type;
var listeners = (0, _listeners.default)(ev.currentTarget, name);
var listeners = (0, _listeners.getListeners)(ev.currentTarget, name);

@@ -74,3 +74,3 @@ if (listeners) {

/**
* Adds a new global event listener
* Adds a new global event listener. Duplicate event handlers will be discarded.
*

@@ -91,6 +91,5 @@ * @function

if (target) {
var listeners = (0, _listeners.default)(target, name);
var length = listeners.push(fn);
var added = (0, _listeners.addListener)(target, name, fn);
if (length === 1) {
if (added && (0, _listeners.getListeners)(target, name).length === 1) {
target.addEventListener(name, dispatcher);

@@ -119,3 +118,3 @@ }

if (target) {
var listeners = (0, _listeners.default)(target, name);
var listeners = (0, _listeners.getListeners)(target, name);
var index = listeners.indexOf(fn);

@@ -122,0 +121,0 @@

@@ -6,3 +6,3 @@ "use strict";

});
exports.getListeners = exports.default = void 0;
exports.addListener = exports.getListeners = exports.default = void 0;
// Simple Map polyfill mapping targets to a hash of names->handler[]

@@ -24,3 +24,16 @@ var targets = [];

exports.getListeners = getListeners;
var addListener = function addListener(target, name, fn) {
var listeners = getListeners(target, name);
if (listeners.indexOf(fn) === -1) {
listeners.push(fn);
return true;
}
return false;
};
exports.addListener = addListener;
var _default = getListeners;
exports.default = _default;

@@ -23,2 +23,13 @@ "use strict";

});
it('should not register duplicate handlers on target', function () {
var handler = _sinon.default.spy();
(0, _dispatcher.on)('localechange', handler, window);
(0, _dispatcher.on)('localechange', handler, window);
var ev = new CustomEvent('localechange', {});
window.dispatchEvent(ev);
var expected = true;
var actual = handler.calledOnce;
expect(actual).to.equal(expected);
});
it('should unregister handlers on target', function () {

@@ -25,0 +36,0 @@ var handler = _sinon.default.spy();

{
"name": "@enact/core",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.",

@@ -5,0 +5,0 @@ "main": "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