Skip to content

Commit

Permalink
Merge pull request #11229 from chancancode/rm-view-lifecycle-hooks
Browse files Browse the repository at this point in the history
[BUGFIX beta] Don't dispatch new lifecycle hooks to views
  • Loading branch information
rwjblue committed May 25, 2015
2 parents 5effe05 + baa4573 commit 2e0936f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ ViewNodeManager.prototype.render = function(env, attrs, visitor) {
if (component) {
var snapshot = takeSnapshot(attrs);
env.renderer.setAttrs(this.component, snapshot);
env.renderer.willCreateElement(component);
env.renderer.willRender(component);
env.renderedViews.push(component.elementId);
}
Expand Down Expand Up @@ -147,10 +146,6 @@ ViewNodeManager.prototype.rerender = function(env, attrs, visitor) {
this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
}

if (component) {
env.lifecycleHooks.push({ type: 'didUpdate', view: component });
}

return newEnv;
}, this);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ QUnit.test('lifecycle hooks are invoked in a predictable order', function() {

// Because the `twitter` attr is only used by the topmost component,
// and not passed down, we do not expect to see lifecycle hooks
// called for child components. If the `willReceiveAttrs` hook used
// called for child components. If the `didReceiveAttrs` hook used
// the new attribute to rerender itself imperatively, that would result
// in lifecycle hooks being invoked for the child.

Expand Down
15 changes: 4 additions & 11 deletions packages/ember-metal-views/lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ Renderer.prototype.createElement =
this.prerenderTopLevelView(view, morph);
};

// inBuffer
Renderer.prototype.willCreateElement = function (/*view*/) {};

Renderer.prototype.didCreateElement = function (view, element) {
if (element) {
view.element = element;
Expand Down Expand Up @@ -161,10 +158,6 @@ Renderer.prototype.didRender = function (view) {
};

Renderer.prototype.updateAttrs = function (view, attrs) {
if (view.willReceiveAttrs) {
view.willReceiveAttrs(attrs);
}

this.setAttrs(view, attrs);
}; // setting new attrs

Expand All @@ -176,8 +169,8 @@ Renderer.prototype.componentUpdateAttrs = function (component, oldAttrs, newAttr
};

Renderer.prototype.willUpdate = function (view, attrs) {
if (view.willUpdate) {
view.willUpdate(attrs);
if (view._willUpdate) {
view._willUpdate(attrs);
}
};

Expand All @@ -186,8 +179,8 @@ Renderer.prototype.componentWillUpdate = function (component) {
};

Renderer.prototype.willRender = function (view) {
if (view.willRender) {
view.willRender();
if (view._willRender) {
view._willRender();
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/ember-views/lib/views/collection_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ var CollectionView = ContainerView.extend(EmptyViewSupport, {
return view;
},

willRender: function() {
_willRender: function() {
var attrs = this.attrs;
var itemProps = buildItemViewProps(this._itemViewTemplate, attrs);
this._itemViewProps = itemProps;
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-views/lib/views/legacy_each_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default View.extend(EmptyViewSupport, {
return controller;
}),

willUpdate(attrs) {
_willUpdate(attrs) {
let itemController = this.getAttrFor(attrs, 'itemController');

if (itemController) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-views/lib/views/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var SelectOption = View.extend({

content: null,

willRender() {
_willRender() {
this.labelPathDidChange();
this.valuePathDidChange();
},
Expand Down Expand Up @@ -651,7 +651,7 @@ var Select = View.extend({
}
},

willRender() {
_willRender() {
this._setDefaults();
},

Expand Down
4 changes: 2 additions & 2 deletions packages/ember-views/tests/views/container_view_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ QUnit.test("should be able to modify childViews then rerender then modify again

var Child = View.extend({
count: 0,
willRender: function() {
_willRender() {
this.count++;
},
template: compile('{{view.label}}')
Expand Down Expand Up @@ -541,7 +541,7 @@ QUnit.test("should be able to modify childViews then rerender again the Containe

var Child = View.extend({
count: 0,
willRender() {
_willRender() {
this.count++;
},
template: compile('{{view.label}}')
Expand Down

0 comments on commit 2e0936f

Please sign in to comment.