react-outlet
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -0,1 +1,7 @@ | ||
2016-12-28 Version 1.0.7 | ||
* Fixed typo when an Outlet id changes | ||
* Added "is_occupied" function to the outlet_registry to check to see if a | ||
particular outlet id is currently occupied. | ||
2016-09-29 Version 1.0.6 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "react-outlet", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Transclusion helpers for React.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,1 +1,3 @@ | ||
/* eslint react/no-find-dom-node: 0, react/no-render-return-value: 0 */ | ||
jest.autoMockOff(); | ||
@@ -35,2 +37,4 @@ | ||
expect(outlet_registry.is_occupied(id)).toBeFalsy(); | ||
var tree = TestUtils.renderIntoDocument( | ||
@@ -43,2 +47,4 @@ <TestDiv> | ||
expect(outlet_registry.is_occupied(id)).toBeTruthy(); | ||
var outlet_content = TestUtils.findRenderedDOMComponentWithClass(tree, "outlet-content"); | ||
@@ -75,2 +81,4 @@ expect(ReactDOM.findDOMNode(outlet_content).textContent).toEqual("winner"); | ||
expect(outlet_registry.is_occupied(id)).toBeFalsy(); | ||
expect(function() { | ||
@@ -84,2 +92,4 @@ TestUtils.findRenderedDOMComponentWithClass(tree, "outlet-content"); | ||
expect(outlet_registry.is_occupied(id)).toBeFalsy(); | ||
expect(function() { | ||
@@ -91,2 +101,4 @@ TestUtils.findRenderedDOMComponentWithClass(tree, "outlet-content"); | ||
expect(outlet_registry.is_occupied(id)).toBeTruthy(); | ||
var outlet_content = TestUtils.findRenderedDOMComponentWithClass(tree, "outlet-content"); | ||
@@ -98,2 +110,4 @@ | ||
expect(outlet_registry.is_occupied(id)).toBeFalsy(); | ||
expect(function() { | ||
@@ -107,4 +121,8 @@ TestUtils.findRenderedDOMComponentWithClass(tree, "outlet-content"); | ||
expect(outlet_registry.is_occupied(id)).toBeTruthy(); | ||
plug_wrap.setState({ renderPlug: false }); | ||
expect(outlet_registry.is_occupied(id)).toBeFalsy(); | ||
expect(function() { | ||
@@ -294,2 +312,21 @@ TestUtils.findRenderedDOMComponentWithClass(tree, "outlet-content"); | ||
it("supports changing its outlet id", function() { | ||
var id = Outlet.new_outlet_id(); | ||
var id2 = Outlet.new_outlet_id(); | ||
var container = document.createElement("div"); | ||
ReactDOM.render(<Outlet outletId={ id } />, container); | ||
expect(outlet_registry.outlets.hasOwnProperty(id)).toBeTruthy(); | ||
expect(outlet_registry.outlets[id].hasOwnProperty("callback")).toBeTruthy(); | ||
ReactDOM.render(<Outlet outletId={ id2 } />, container); | ||
// id has been removed | ||
expect(outlet_registry.outlets.hasOwnProperty(id)).toBeFalsy(); | ||
// ...and has been replaced with id2 | ||
expect(outlet_registry.outlets.hasOwnProperty(id2)).toBeTruthy(); | ||
expect(outlet_registry.outlets[id2].hasOwnProperty("callback")).toBeTruthy(); | ||
}); | ||
}); | ||
@@ -296,0 +333,0 @@ |
@@ -23,3 +23,3 @@ function OutletRegistry() { | ||
if (outlet.hasOwnProperty("component")) { | ||
// the plug got there first, do an initial update | ||
// the plug registered first, do an initial update | ||
outlet.callback(outlet.component); | ||
@@ -63,2 +63,9 @@ } | ||
OutletRegistry.prototype.is_occupied = function(outlet_id) { | ||
if (this.outlets.hasOwnProperty(outlet_id)) { | ||
return this.outlets[outlet_id].component !== undefined; | ||
} | ||
return false; | ||
}; | ||
OutletRegistry.prototype.reset = function(){ | ||
@@ -65,0 +72,0 @@ this.outlets = {}; |
@@ -24,3 +24,3 @@ var React = require("react"); | ||
if (this.props.outletId !== next_props.outletId) { | ||
registry.unregister(this.props.outletId); | ||
registry.unregister_outlet(this.props.outletId); | ||
registry.register(next_props.outletId, this.update); | ||
@@ -27,0 +27,0 @@ } |
@@ -11,6 +11,6 @@ var React = require("react"); | ||
componentDidMount: function() { | ||
this.send_children(this.props.children || null); | ||
this.send_children(this.props.children || undefined); | ||
}, | ||
componentWillReceiveProps: function(next_props) { | ||
this.send_children(next_props.children || null); | ||
this.send_children(next_props.children || undefined); | ||
}, | ||
@@ -17,0 +17,0 @@ |
31028
441