New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lion/overlays

Package Overview
Dependencies
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lion/overlays - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [0.5.0](https://github.com/ing-bank/lion/compare/@lion/overlays@0.4.0...@lion/overlays@0.5.0) (2019-09-26)
### Features
* **overlays:** delegate events in DynamicOverlayController ([20037ba](https://github.com/ing-bank/lion/commit/20037ba))
# [0.4.0](https://github.com/ing-bank/lion/compare/@lion/overlays@0.3.12...@lion/overlays@0.4.0) (2019-09-25)

@@ -8,0 +19,0 @@

4

package.json
{
"name": "@lion/overlays",
"version": "0.4.0",
"version": "0.5.0",
"description": "Overlays System using lit-html for rendering",

@@ -43,3 +43,3 @@ "author": "ing-bank",

},
"gitHead": "ab0b87146323b5f368c267de8bd96442fff430ea"
"gitHead": "6cdd15d68949063976eddff4ebc38f7940c6b7d6"
}

@@ -37,2 +37,4 @@ import { LocalOverlayController } from './LocalOverlayController.js';

}
this.__fakeExtendsEventTarget();
this.__delegateEvent = this.__delegateEvent.bind(this);
}

@@ -75,5 +77,9 @@

}
const prevActive = this.active;
this.active.switchOut();
ctrlToSwitchTo.switchIn();
this.__active = ctrlToSwitchTo;
this._delegateEvents(this.__active, prevActive);
}

@@ -104,2 +110,22 @@

}
_delegateEvents(active, prevActive) {
['show', 'hide'].forEach(event => {
active.addEventListener(event, this.__delegateEvent);
prevActive.removeEventListener(event, this.__delegateEvent);
});
}
__delegateEvent(ev) {
ev.stopPropagation();
this.dispatchEvent(new Event(ev.type));
}
// TODO: this method has to be removed when EventTarget polyfill is available on IE11
__fakeExtendsEventTarget() {
const delegate = document.createDocumentFragment();
['addEventListener', 'dispatchEvent', 'removeEventListener'].forEach(funcName => {
this[funcName] = (...args) => delegate[funcName](...args);
});
}
}

@@ -136,2 +136,32 @@ import { expect, html } from '@open-wc/testing';

});
describe('API abstraction for active overlay controller', () => {
describe('Events', () => {
it('delegates "show/hide" event', async () => {
const ctrl = new DynamicOverlayController();
const global = new FakeGlobalCtrl(defaultOptions);
const local = new FakeLocalCtrl(defaultOptions);
ctrl.add(global);
ctrl.add(local);
ctrl.switchTo(local);
const showSpy = sinon.spy();
const hideSpy = sinon.spy();
ctrl.addEventListener('show', showSpy);
ctrl.addEventListener('hide', hideSpy);
await ctrl.show();
expect(showSpy.callCount).to.equal(1);
await ctrl.hide();
expect(hideSpy.callCount).to.equal(1);
ctrl.switchTo(global);
await ctrl.show();
expect(showSpy.callCount).to.equal(2);
await ctrl.hide();
expect(hideSpy.callCount).to.equal(2);
});
});
});
});
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