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

[WIP] Remove Ember.ContainerView. #13188

Closed
wants to merge 1 commit into from
Closed
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
27 changes: 0 additions & 27 deletions packages/ember-htmlbars/tests/helpers/view_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import run from 'ember-metal/run_loop';
import jQuery from 'ember-views/system/jquery';
import TextField from 'ember-views/views/text_field';
import EmberObject from 'ember-runtime/system/object';
import ContainerView from 'ember-views/views/container_view';
import SafeString from 'htmlbars-util/safe-string';
import precompile from 'ember-template-compiler/compat/precompile';
import compile from 'ember-template-compiler/system/compile';
Expand Down Expand Up @@ -1017,32 +1016,6 @@ QUnit.test('should expose a controller that can be used in the view instance', f
equal(controller, childThingController, 'childThing should get the same controller as the outer scope');
});

QUnit.test('should expose a controller keyword that persists through Ember.ContainerView', function() {
var templateString = '{{view view.containerView}}';
view = EmberView.create({
[OWNER]: owner,
containerView: ContainerView,
controller: EmberObject.create({
foo: 'bar'
}),

template: compile(templateString)
});

runAppend(view);

var containerView = get(view, 'childViews.firstObject');
var viewInstanceToBeInserted = EmberView.create({
template: compile('{{controller.foo}}')
});

run(function() {
containerView.pushObject(viewInstanceToBeInserted);
});

equal(trim(viewInstanceToBeInserted.$().text()), 'bar', 'renders value from parent\'s controller');
});

QUnit.test('should work with precompiled templates', function() {
var templateString = precompile('{{view.value}}');
var compiledTemplate = template(eval(templateString));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import EmberView from 'ember-views/views/view';
import { Binding } from 'ember-metal/binding';
import EmberObject from 'ember-runtime/system/object';
import { computed } from 'ember-metal/computed';
import ContainerView from 'ember-views/views/container_view';
import compile from 'ember-template-compiler/system/compile';
import { runAppend, runDestroy } from 'ember-runtime/tests/utils';
import { registerHelper } from 'ember-htmlbars/helpers';

import { set } from 'ember-metal/property_set';

import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils';
import viewKeyword from 'ember-htmlbars/keywords/view';

Expand Down Expand Up @@ -119,57 +116,6 @@ QUnit.test('should cleanup bound properties on rerender', function() {
equal(view.$().text(), 'wycats', 'rendered binding');
});

QUnit.test('should update bound values after view\'s parent is removed and then re-appended', function() {
expectDeprecation('Setting `childViews` on a Container is deprecated.');

var controller = EmberObject.create();

var parentView = ContainerView.create({
childViews: ['testView'],

controller: controller,

testView: EmberView.create({
template: compile('{{#if showStuff}}{{boundValue}}{{else}}Not true.{{/if}}')
})
});

controller.setProperties({
showStuff: true,
boundValue: 'foo'
});

runAppend(parentView);
view = parentView.get('testView');

equal(trim(view.$().text()), 'foo');
run(function() {
set(controller, 'showStuff', false);
});
equal(trim(view.$().text()), 'Not true.');

run(function() {
set(controller, 'showStuff', true);
});
equal(trim(view.$().text()), 'foo');

run(function() {
parentView.remove();
set(controller, 'showStuff', false);
});
run(function() {
set(controller, 'showStuff', true);
});
runAppend(parentView);

run(function() {
set(controller, 'boundValue', 'bar');
});
equal(trim(view.$().text()), 'bar');

runDestroy(parentView);
});

QUnit.test('should accept bindings as a string or an Ember.Binding', function() {
var ViewWithBindings = EmberView.extend({
twoWayBindingTestBinding: Binding.from('context.direction'),
Expand Down
2 changes: 0 additions & 2 deletions packages/ember-views/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
import { Renderer } from 'ember-metal-views';
import { DeprecatedCoreView } from 'ember-views/views/core_view';
import { DeprecatedView } from 'ember-views/views/view';
import { DeprecatedContainerView } from 'ember-views/views/container_view';
import Component from 'ember-views/components/component';

import EventDispatcher from 'ember-views/system/event_dispatcher';
Expand Down Expand Up @@ -59,7 +58,6 @@ if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) {
Ember.View.states = states;
Ember.View.cloneStates = cloneStates;
Ember.View._Renderer = Renderer;
Ember.ContainerView = DeprecatedContainerView;
}

Ember._Renderer = Renderer;
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-views/lib/mixins/view_context_support.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var ViewContextSupport = Mixin.create(LegacyViewSupport, {

1. Supplied context (usually by Handlebars)
2. Specified controller
3. `parentView`'s context (for a child of a ContainerView)
3. `parentView`'s context

The code in Handlebars that overrides the `_context` property first
checks to see whether the view has a specified controller. This is
Expand Down
11 changes: 5 additions & 6 deletions packages/ember-views/lib/mixins/view_support.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,9 @@ export default Mixin.create({
finished synchronizing.

This is not typically a function that you will need to call directly when
building your application. You might consider using `Ember.ContainerView`
instead. If you do need to use `appendTo`, be sure that the target element
you are providing is associated with an `Ember.Application` and does not
have an ancestor element that is associated with an Ember view.
building your application. If you do need to use `appendTo`, be sure that
the target element you are providing is associated with an `Ember.Application`
and does not have an ancestor element that is associated with an Ember view.

@method appendTo
@param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object
Expand All @@ -263,7 +262,7 @@ export default Mixin.create({
let target = $(selector);

assert('You tried to append to (' + selector + ') but that isn\'t in the DOM', target.length > 0);
assert('You cannot append to an existing Ember.View. Consider using Ember.ContainerView instead.', !target.is('.ember-view') && !target.parents().is('.ember-view'));
assert('You cannot append to an existing Ember.View.', !target.is('.ember-view') && !target.parents().is('.ember-view'));

this.renderer.appendTo(this, target[0]);
} else {
Expand Down Expand Up @@ -349,7 +348,7 @@ export default Mixin.create({
var target = jQuery(selector);

assert('You tried to replace in (' + selector + ') but that isn\'t in the DOM', target.length > 0);
assert('You cannot replace an existing Ember.View. Consider using Ember.ContainerView instead.', !target.is('.ember-view') && !target.parents().is('.ember-view'));
assert('You cannot replace an existing Ember.View.', !target.is('.ember-view') && !target.parents().is('.ember-view'));

this.renderer.replaceIn(this, target[0]);

Expand Down
Loading