react-gateway
Advanced tools
Comparing version 2.5.0 to 2.6.0
@@ -34,2 +34,3 @@ 'use strict'; | ||
Gateway.prototype.componentWillMount = function componentWillMount() { | ||
this.id = this.gatewayRegistry.register(this.props.into, this.props.children); | ||
this.renderIntoGatewayNode(this.props); | ||
@@ -39,3 +40,3 @@ }; | ||
Gateway.prototype.componentWillReceiveProps = function componentWillReceiveProps(props) { | ||
this.gatewayRegistry.clearChild(this.props.into, this.props.children); | ||
this.gatewayRegistry.clearChild(this.props.into, this.id); | ||
this.renderIntoGatewayNode(props); | ||
@@ -45,7 +46,7 @@ }; | ||
Gateway.prototype.componentWillUnmount = function componentWillUnmount() { | ||
this.gatewayRegistry.removeChild(this.props.into, this.props.children); | ||
this.gatewayRegistry.unregister(this.props.into, this.id); | ||
}; | ||
Gateway.prototype.renderIntoGatewayNode = function renderIntoGatewayNode(props) { | ||
this.gatewayRegistry.addChild(this.props.into, props.children); | ||
this.gatewayRegistry.addChild(this.props.into, this.id, props.children); | ||
}; | ||
@@ -52,0 +53,0 @@ |
@@ -13,6 +13,11 @@ "use strict"; | ||
this._children = {}; | ||
// Unique key for children of a gateway | ||
this._currentId = 0; | ||
} | ||
GatewayRegistry.prototype._renderContainer = function _renderContainer(name) { | ||
if (!this._containers[name]) { | ||
var _this = this; | ||
if (!this._containers[name] || !this._children[name]) { | ||
return; | ||
@@ -22,3 +27,5 @@ } | ||
this._containers[name].setState({ | ||
children: this._children[name] | ||
children: Object.keys(this._children[name]).sort().map(function (id) { | ||
return _this._children[name][id]; | ||
}) | ||
}); | ||
@@ -36,16 +43,23 @@ }; | ||
GatewayRegistry.prototype.addChild = function addChild(name, child) { | ||
this._children[name] = this._children[name] || []; | ||
this._children[name].push(child); | ||
GatewayRegistry.prototype.addChild = function addChild(name, gatewayId, child) { | ||
this._children[name][gatewayId] = child; | ||
this._renderContainer(name); | ||
}; | ||
GatewayRegistry.prototype.clearChild = function clearChild(name, child) { | ||
this._children[name] = this._children[name].filter(function (item) { | ||
return item !== child; | ||
}); | ||
GatewayRegistry.prototype.clearChild = function clearChild(name, gatewayId) { | ||
delete this._children[name][gatewayId]; | ||
}; | ||
GatewayRegistry.prototype.removeChild = function removeChild(name, child) { | ||
this.clearChild(name, child); | ||
GatewayRegistry.prototype.register = function register(name, child) { | ||
this._children[name] = this._children[name] || {}; | ||
var gatewayId = name + "_" + this._currentId; | ||
this._children[name][gatewayId] = child; | ||
this._currentId += 1; | ||
return gatewayId; | ||
}; | ||
GatewayRegistry.prototype.unregister = function unregister(name, gatewayId) { | ||
this.clearChild(name, gatewayId); | ||
this._renderContainer(name); | ||
@@ -52,0 +66,0 @@ }; |
{ | ||
"name": "react-gateway", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Render React DOM into a new context", | ||
@@ -5,0 +5,0 @@ "main": "lib/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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
18769
192
0