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

@atlaskit/portal

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atlaskit/portal - npm Package Compare versions

Comparing version 3.1.1 to 3.1.2

dist/cjs/components/Portal.d.ts

16

CHANGELOG.md
# @atlaskit/portal
## 3.1.2
### Patch Changes
- [patch][adc048de7e](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/adc048de7e):
Fixing ie11 bug caused by using Event constructor
## 3.1.1
**Warning: Do not use this version. It has been deprecated**
It is broken for ie11 if you are not polyfilling the `new Event` constructor
### Patch Changes

@@ -13,2 +25,6 @@

**Warning: Do not use this version. It has been deprecated**
It is broken for ie11 if you are not polyfilling the `new Event` constructor
### Minor Changes

@@ -15,0 +31,0 @@

62

dist/cjs/components/Portal.js

@@ -16,17 +16,6 @@ "use strict";

};
var body = function () {
var getBody = function () {
tiny_invariant_1.default(document && document.body, 'cannot find document.body');
return document.body;
};
var portalParent = function () {
var parentElement = document.querySelector('body > .atlaskit-portal-container');
if (!parentElement) {
var parent_1 = document.createElement('div');
parent_1.setAttribute('class', 'atlaskit-portal-container');
parent_1.setAttribute('style', "display: flex;");
body().appendChild(parent_1);
return parent_1;
}
return parentElement;
};
var zIndexToName = Object.keys(theme_1.layers).reduce(function (acc, name) {

@@ -42,10 +31,39 @@ var value = theme_1.layers[name]();

};
var fireMountUnmountEvent = function (eventName, zIndex) {
var event = new Event(eventName);
event.detail = {
var getEvent = function (eventName, zIndex) {
var detail = {
layer: getLayerName(Number(zIndex)),
zIndex: zIndex,
};
// In ie11 the CustomEvent object exists, but it cannot be used as a constructor
if (typeof CustomEvent === 'function') {
return new CustomEvent(eventName, {
detail: detail,
});
}
// CustomEvent constructor API not supported (ie11)
// Using `new Event` or `new CustomEvent` does not work in ie11
var event = document.createEvent('CustomEvent');
var params = {
bubbles: true,
cancellable: true,
detail: detail,
};
event.initCustomEvent(eventName, params.bubbles, params.cancellable, params.detail);
return event;
};
var firePortalEvent = function (eventName, zIndex) {
var event = getEvent(eventName, zIndex);
window.dispatchEvent(event);
};
var getPortalParent = function () {
var parentElement = document.querySelector('body > .atlaskit-portal-container');
if (!parentElement) {
var parent_1 = document.createElement('div');
parent_1.setAttribute('class', 'atlaskit-portal-container');
parent_1.setAttribute('style', "display: flex;");
getBody().appendChild(parent_1);
return parent_1;
}
return parentElement;
};
// This is a generic component does two things:

@@ -70,3 +88,3 @@ // 1. Portals it's children using React.createPortal

var newContainer = createContainer(zIndex);
portalParent().replaceChild(container, newContainer);
getPortalParent().replaceChild(container, newContainer);
// eslint-disable-next-line react/no-did-update-set-state

@@ -77,3 +95,3 @@ this.setState({ container: newContainer });

// SSR path
portalParent().appendChild(container);
getPortalParent().appendChild(container);
}

@@ -85,3 +103,3 @@ };

if (container) {
portalParent().appendChild(container);
getPortalParent().appendChild(container);
}

@@ -98,3 +116,3 @@ else {

});
fireMountUnmountEvent(constants_1.PORTAL_MOUNT_EVENT, Number(zIndex));
firePortalEvent(constants_1.PORTAL_MOUNT_EVENT, Number(zIndex));
};

@@ -105,10 +123,10 @@ Portal.prototype.componentWillUnmount = function () {

if (container) {
portalParent().removeChild(container);
getPortalParent().removeChild(container);
// clean up parent element if there are no more portals
var portals = !!document.querySelector('body > .atlaskit-portal-container > .atlaskit-portal');
if (!portals) {
body().removeChild(portalParent());
getBody().removeChild(getPortalParent());
}
}
fireMountUnmountEvent(constants_1.PORTAL_UNMOUNT_EVENT, Number(zIndex));
firePortalEvent(constants_1.PORTAL_UNMOUNT_EVENT, Number(zIndex));
};

@@ -115,0 +133,0 @@ Portal.prototype.render = function () {

{
"name": "@atlaskit/portal",
"version": "3.1.1",
"version": "3.1.2",
"sideEffects": false
}

@@ -14,17 +14,6 @@ import { __extends } from "tslib";

};
var body = function () {
var getBody = function () {
invariant(document && document.body, 'cannot find document.body');
return document.body;
};
var portalParent = function () {
var parentElement = document.querySelector('body > .atlaskit-portal-container');
if (!parentElement) {
var parent_1 = document.createElement('div');
parent_1.setAttribute('class', 'atlaskit-portal-container');
parent_1.setAttribute('style', "display: flex;");
body().appendChild(parent_1);
return parent_1;
}
return parentElement;
};
var zIndexToName = Object.keys(layers).reduce(function (acc, name) {

@@ -40,10 +29,39 @@ var value = layers[name]();

};
var fireMountUnmountEvent = function (eventName, zIndex) {
var event = new Event(eventName);
event.detail = {
var getEvent = function (eventName, zIndex) {
var detail = {
layer: getLayerName(Number(zIndex)),
zIndex: zIndex,
};
// In ie11 the CustomEvent object exists, but it cannot be used as a constructor
if (typeof CustomEvent === 'function') {
return new CustomEvent(eventName, {
detail: detail,
});
}
// CustomEvent constructor API not supported (ie11)
// Using `new Event` or `new CustomEvent` does not work in ie11
var event = document.createEvent('CustomEvent');
var params = {
bubbles: true,
cancellable: true,
detail: detail,
};
event.initCustomEvent(eventName, params.bubbles, params.cancellable, params.detail);
return event;
};
var firePortalEvent = function (eventName, zIndex) {
var event = getEvent(eventName, zIndex);
window.dispatchEvent(event);
};
var getPortalParent = function () {
var parentElement = document.querySelector('body > .atlaskit-portal-container');
if (!parentElement) {
var parent_1 = document.createElement('div');
parent_1.setAttribute('class', 'atlaskit-portal-container');
parent_1.setAttribute('style', "display: flex;");
getBody().appendChild(parent_1);
return parent_1;
}
return parentElement;
};
// This is a generic component does two things:

@@ -68,3 +86,3 @@ // 1. Portals it's children using React.createPortal

var newContainer = createContainer(zIndex);
portalParent().replaceChild(container, newContainer);
getPortalParent().replaceChild(container, newContainer);
// eslint-disable-next-line react/no-did-update-set-state

@@ -75,3 +93,3 @@ this.setState({ container: newContainer });

// SSR path
portalParent().appendChild(container);
getPortalParent().appendChild(container);
}

@@ -83,3 +101,3 @@ };

if (container) {
portalParent().appendChild(container);
getPortalParent().appendChild(container);
}

@@ -96,3 +114,3 @@ else {

});
fireMountUnmountEvent(PORTAL_MOUNT_EVENT, Number(zIndex));
firePortalEvent(PORTAL_MOUNT_EVENT, Number(zIndex));
};

@@ -103,10 +121,10 @@ Portal.prototype.componentWillUnmount = function () {

if (container) {
portalParent().removeChild(container);
getPortalParent().removeChild(container);
// clean up parent element if there are no more portals
var portals = !!document.querySelector('body > .atlaskit-portal-container > .atlaskit-portal');
if (!portals) {
body().removeChild(portalParent());
getBody().removeChild(getPortalParent());
}
}
fireMountUnmountEvent(PORTAL_UNMOUNT_EVENT, Number(zIndex));
firePortalEvent(PORTAL_UNMOUNT_EVENT, Number(zIndex));
};

@@ -113,0 +131,0 @@ Portal.prototype.render = function () {

{
"name": "@atlaskit/portal",
"version": "3.1.1",
"version": "3.1.2",
"sideEffects": false
}
{
"name": "@atlaskit/portal",
"version": "3.1.1",
"version": "3.1.2",
"description": "Atlaskit wrapper for rendering components in React portals",

@@ -5,0 +5,0 @@ "repository": "https://bitbucket.org/atlassian/atlaskit-mk-2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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