Skip to content

Commit

Permalink
Fixes remaining places that use "config" instead of "props" - Fixes #149
Browse files Browse the repository at this point in the history


There were some remaining places in IncrementalDomRenderer that were still accessing the `config` object from child elements instead of `props`. The main object should be `props`.
  • Loading branch information
mairatma committed Aug 8, 2016
1 parent f43bf77 commit bfdfd7a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/metal-incremental-dom/src/IncrementalDomRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ class IncrementalDomRenderer extends ComponentRenderer {
* @protected
*/
handleChildrenCaptured_(tree) {
var {config, tag} = this.componentToRender_;
config.children = this.buildChildren_(tree.config.children);
var {props, tag} = this.componentToRender_;
props.children = this.buildChildren_(tree.props.children);
this.componentToRender_ = null;
this.renderFromTag_(tag, config);
this.renderFromTag_(tag, props);
}

/**
Expand All @@ -323,8 +323,8 @@ class IncrementalDomRenderer extends ComponentRenderer {
*/
handleChildRender_(node) {
if (node.tag && IncrementalDomUtils.isComponentTag(node.tag)) {
node.config.children = this.buildChildren_(node.config.children);
this.renderFromTag_(node.tag, node.config);
node.props.children = this.buildChildren_(node.props.children);
this.renderFromTag_(node.tag, node.props);
return true;
}
}
Expand Down Expand Up @@ -488,9 +488,9 @@ class IncrementalDomRenderer extends ComponentRenderer {
* @protected
*/
handleSubComponentCall_(originalFn, ...args) {
var config = IncrementalDomUtils.buildConfigFromCall(args);
var props = IncrementalDomUtils.buildConfigFromCall(args);
this.componentToRender_ = {
config,
props,
tag: args[0]
};
IncrementalDomChildren.capture(this, this.handleChildrenCaptured_);
Expand Down
45 changes: 45 additions & 0 deletions packages/metal-incremental-dom/test/IncrementalDomRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,51 @@ describe('IncrementalDomRenderer', function() {
assert.strictEqual(child2.element, child1.element.childNodes[0]);
});

it('should render children components with changed props', function() {
class TestChildComponent extends Component {
render() {
IncrementalDOM.elementOpen('child');
if (this.children.length) {
this.children[0].props = object.mixin({}, this.children[0].props, {
foo: 'changedFoo'
});
this.children.forEach(IncrementalDomRenderer.renderChild);
}
if (this.foo) {
IncrementalDOM.text(this.foo);
}
IncrementalDOM.elementClose('child');
}
}
TestChildComponent.RENDERER = IncrementalDomRenderer;
TestChildComponent.STATE = {
foo: {
}
};

class TestNestedChildComponent extends Component {
render() {
IncDom.elementOpen(TestChildComponent);
this.children.forEach(IncrementalDomRenderer.renderChild);
IncDom.elementClose(TestChildComponent);
}
}
TestNestedChildComponent.RENDERER = IncrementalDomRenderer;

class TestComponent extends Component {
render() {
IncDom.elementOpen(TestNestedChildComponent);
IncDom.elementVoid(TestChildComponent, null, null, 'foo', 'foo');
IncDom.elementClose(TestNestedChildComponent);
}
}
TestComponent.RENDERER = IncrementalDomRenderer;
component = new TestComponent();

assert.strictEqual(1, component.element.childNodes.length);
assert.strictEqual('changedFoo', component.element.childNodes[0].textContent);
});

it('should render correctly when recursive children are used', function() {
class TestChildComponent extends Component {
render() {
Expand Down

0 comments on commit bfdfd7a

Please sign in to comment.