Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Don't dispatch new lifecycle hooks to views #11229

Merged
merged 1 commit into from
May 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -116,9 +116,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 @@ -160,10 +157,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 @@ -175,8 +168,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 @@ -185,8 +178,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 @@ -401,7 +401,7 @@ var CollectionView = ContainerView.extend({
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 @@ -27,7 +27,7 @@ export default View.extend({
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