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

Remove View#createElement / View#destroyElement. #13892

Merged
merged 2 commits into from
Jul 26, 2016
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
13 changes: 1 addition & 12 deletions packages/ember-htmlbars/lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ Renderer.prototype.revalidateTopLevelView =
// This guard prevents revalidation on an already-destroyed view.
if (view._renderNode.lastResult) {
view._renderNode.lastResult.revalidate(view.env);
// supports createElement, which operates without moving the view into
// the inDOM state.
if (view._state === 'inDOM') {
this.dispatchLifecycleHooks(view.env);
}
this.dispatchLifecycleHooks(view.env);
this.clearRenderedViews(view.env);
}
};
Expand Down Expand Up @@ -149,13 +145,6 @@ Renderer.prototype.replaceIn =
run.scheduleOnce('render', this, this.renderTopLevelView, view, morph);
};

Renderer.prototype.createElement =
function Renderer_createElement(view) {
let morph = this._dom.createFragmentMorph();
morph.ownerNode = morph;
this.prerenderTopLevelView(view, morph);
};

Renderer.prototype.didCreateElement = function (view, element) {
if (element) {
view.element = element;
Expand Down
47 changes: 0 additions & 47 deletions packages/ember-views/lib/mixins/view_support.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ export default Mixin.create({
/**
Appends the view's element to the specified parent element.

If the view does not have an HTML representation yet, `createElement()`
will be called automatically.

Note that this method just schedules the view to be appended; the DOM
element will not be appended to the given element until all bindings have
finished synchronizing.
Expand Down Expand Up @@ -297,26 +294,6 @@ export default Mixin.create({
return jQuery(id)[0] || jQuery(id, parentElem)[0];
},

/**
Creates a DOM representation of the view and all of its child views by
recursively calling the `render()` method. Once the element is created,
it sets the `element` property of the view to the rendered element.

After the element has been inserted into the DOM, `didInsertElement` will
be called on this view and all of its child views.

@method createElement
@return {Ember.View} receiver
@private
*/
createElement() {
if (this.element) { return this; }

this.renderer.createElement(this);

return this;
},

/**
Called when a view is going to insert an element into the DOM.

Expand Down Expand Up @@ -348,30 +325,6 @@ export default Mixin.create({
*/
willClearRender: K,

/**
Destroys any existing element along with the element for any child views
as well. If the view does not currently have a element, then this method
will do nothing.

If you implement `willDestroyElement()` on your view, then this method will
be invoked on your view before your element is destroyed to give you a
chance to clean up any event handlers, etc.

If you write a `willDestroyElement()` handler, you can assume that your
`didInsertElement()` handler was called earlier for the same element.

You should not call or override this method yourself, but you may
want to implement the above callbacks.

@method destroyElement
@return {Ember.View} receiver
@private
*/
destroyElement() {
this._currentState.destroyElement(this);
return this;
},

/**
You must call `destroy` on a view to destroy the view (and all of its
child views). This will remove the view from any parent node, then make
Expand Down
2 changes: 0 additions & 2 deletions packages/ember-views/lib/views/states/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export default {
return true; // continue event propagation
},

destroyElement() { },

destroy() { },

rerender(view) {
Expand Down
3 changes: 0 additions & 3 deletions packages/ember-views/lib/views/states/destroying.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ assign(destroying, {
},
rerender() {
throw new EmberError('You can\'t call rerender on a view being destroyed');
},
destroyElement() {
throw new EmberError('You can\'t call destroyElement on a view being destroyed');
}
});

Expand Down
4 changes: 0 additions & 4 deletions packages/ember-views/lib/views/states/has_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ assign(hasElement, {
view.renderer.rerender(view);
},

destroyElement(view) {
view.renderer.remove(view, false);
},

destroy(view) {
view.renderer.remove(view, true);
},
Expand Down
6 changes: 0 additions & 6 deletions packages/ember-views/tests/views/instrumentation_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,3 @@ QUnit.test('generates the proper instrumentation details when called directly',

confirmPayload(payload, view);
});

QUnit.test('should add ember-view to views', function() {
run(view, 'createElement');

confirmPayload(beforeCalls[0], view);
});
22 changes: 0 additions & 22 deletions packages/ember-views/tests/views/view/append_to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,6 @@ QUnit.test('raises an assert when a target does not exist in the DOM', function(
});


QUnit.test('remove removes an element from the DOM', function() {
willDestroyCalled = 0;

view = View.create({
willDestroyElement() {
willDestroyCalled++;
}
});

ok(!get(view, 'element'), 'precond - should not have an element');

run(() => view.append());

ok(jQuery('#' + get(view, 'elementId')).length === 1, 'precond - element was inserted');

run(() => view.destroyElement());

ok(jQuery('#' + get(view, 'elementId')).length === 0, 'remove removes an element from the DOM');
ok(!get(view, 'element'), 'remove nulls out the element');
equal(willDestroyCalled, 1, 'the willDestroyElement hook was called once');
});

QUnit.test('destroy more forcibly removes the view', function() {
willDestroyCalled = 0;

Expand Down
38 changes: 0 additions & 38 deletions packages/ember-views/tests/views/view/create_element_test.js

This file was deleted.

51 changes: 0 additions & 51 deletions packages/ember-views/tests/views/view/destroy_element_test.js

This file was deleted.