Skip to content

Commit

Permalink
Remove Ember.ContainerView cont.
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroicEric committed Mar 28, 2016
1 parent 8ee5ff2 commit 2e99a02
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 56 deletions.
1 change: 0 additions & 1 deletion packages/ember-htmlbars/lib/templates/container-view.hbs

This file was deleted.

21 changes: 9 additions & 12 deletions packages/ember-views/tests/system/event_dispatcher_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ QUnit.test('should send change events up view hierarchy if view contains form el
});

QUnit.test('events should stop propagating if the view is destroyed', function() {
var parentViewReceived, receivedEvent;
var parentComponentReceived, receivedEvent;

owner.register('component:x-foo', Component.extend({
layout: compile('<input id="is-done" type="checkbox" />'),
change(evt) {
receivedEvent = true;
run(() => {
Expand All @@ -167,25 +168,21 @@ QUnit.test('events should stop propagating if the view is destroyed', function()
}
}));

owner.register('template:components/x-foo', compile('<input id="is-done" type="checkbox"'));

var parentView = Component.create({
let parentComponent = Component.extend({
[OWNER]: owner,

layout: compile('{{x-foo}}'),

change(evt) {
parentViewReceived = true;
parentComponentReceived = true;
}
});
}).create();

runAppend(parentView);
runAppend(parentComponent);

ok(jQuery('#is-done').length, 'precond - view is in the DOM');
ok(jQuery('#is-done').length, 'precond - component is in the DOM');
jQuery('#is-done').trigger('change');
ok(!jQuery('#is-done').length, 'precond - view is not in the DOM');
ok(!jQuery('#is-done').length, 'precond - component is not in the DOM');
ok(receivedEvent, 'calls change method when a child element is changed');
ok(!parentViewReceived, 'parent view does not receive the event');
ok(!parentComponentReceived, 'parent component does not receive the event');
});

QUnit.test('should dispatch events to nearest event manager', function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { get } from 'ember-metal/property_get';
import run from 'ember-metal/run_loop';
import EmberView from 'ember-views/views/view';
import { equalHTML } from 'ember-views/tests/test-helpers/equal-html';
import compile from 'ember-template-compiler/system/compile';

import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils';
Expand Down
2 changes: 0 additions & 2 deletions packages/ember-views/tests/views/view/destroy_element_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import EmberView from 'ember-views/views/view';
import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils';
import viewKeyword from 'ember-htmlbars/keywords/view';

import { objectAt } from 'ember-runtime/mixins/array';

var originalViewKeyword;
var view;

Expand Down
2 changes: 0 additions & 2 deletions packages/ember-views/tests/views/view/element_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import run from 'ember-metal/run_loop';

import EmberView from 'ember-views/views/view';

import { objectAt } from 'ember-runtime/mixins/array';

var parentView, view;

QUnit.module('Ember.View#element', {
Expand Down
5 changes: 1 addition & 4 deletions packages/ember-views/tests/views/view/is_visible_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import EmberView from 'ember-views/views/view';
import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils';
import viewKeyword from 'ember-htmlbars/keywords/view';

import { objectAt } from 'ember-runtime/mixins/array';

var View, view, parentBecameVisible, childBecameVisible, grandchildBecameVisible;
var parentBecameHidden, childBecameHidden, grandchildBecameHidden;
var view;
var warnings, originalWarn;
var originalViewKeyword;

Expand Down
69 changes: 40 additions & 29 deletions packages/ember-views/tests/views/view/remove_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,46 @@ import { get } from 'ember-metal/property_get';
import run from 'ember-metal/run_loop';
import jQuery from 'ember-views/system/jquery';
import View from 'ember-views/views/view';
import { compile } from 'ember-template-compiler';

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

import { objectAt } from 'ember-runtime/mixins/array';

import { runAppend, runDestroy } from 'ember-runtime/tests/utils';

var parentView, child;
var originalViewKeyword;

import isEnabled from 'ember-metal/features';
if (!isEnabled('ember-glimmer')) {
// jscs:disable

// .......................................................
// removeAllChildren()
//
var view, childViews;
QUnit.module('View#removeAllChildren', {
setup() {
originalViewKeyword = registerKeyword('view', viewKeyword);
expectDeprecation('Setting `childViews` on a Container is deprecated.');

view = ContainerView.create({
childViews: [View, View, View]
});
childViews = view.get('childViews');
view = View.extend({
template: compile(`
{{view view.childView1}}
{{view view.childView2}}
{{view view.childView3}}
`),
childView1: View.extend(),
childView2: View.extend(),
childView3: View.extend()
}).create();
runAppend(view);

childViews = get(view, 'childViews');
},
teardown() {
run(function() {
childViews.forEach(function(v) { v.destroy(); });
view.destroy();
});
childViews.forEach((v) => runDestroy(v));
runDestroy(view);
resetKeyword('view', originalViewKeyword);
}
});
Expand Down Expand Up @@ -63,21 +74,18 @@ QUnit.module('View#removeFromParent', {
}
});

import isEnabled from 'ember-metal/features';
if (!isEnabled('ember-glimmer')) {
// jscs:disable

QUnit.test('removes view from parent view', function() {
expectDeprecation('Setting `childViews` on a Container is deprecated.');
parentView = View.extend({
template: compile('{{view view.childView}}'),
childView: View.extend({
template: compile('child view template')
})
}).create();
run(parentView, parentView.append);

parentView = ContainerView.create({ childViews: [View] });
child = objectAt(get(parentView, 'childViews'), 0);
ok(get(child, 'parentView'), 'precond - has parentView');

run(function() {
parentView.createElement();
});

ok(parentView.$('div').length, 'precond - has a child DOM element');

run(function() {
Expand All @@ -89,16 +97,18 @@ QUnit.test('removes view from parent view', function() {
equal(parentView.$('div').length, 0, 'removes DOM element from parent');
});

}

QUnit.test('returns receiver', function() {
expectDeprecation('Setting `childViews` on a Container is deprecated.');

parentView = ContainerView.create({ childViews: [View] });
parentView = View.extend({
template: compile('{{view view.childView}}'),
childView: View.extend({
template: compile('child view template')
})
}).create();

run(parentView, parentView.append);
child = objectAt(get(parentView, 'childViews'), 0);
var removed = run(function() {
return child.removeFromParent();
});

let removed = run(() => child.removeFromParent());

equal(removed, child, 'receiver');
});
Expand All @@ -116,7 +126,6 @@ QUnit.test('does nothing if not in parentView', function() {
});
});


QUnit.test('the DOM element is gone after doing append and remove in two separate runloops', function() {
view = View.create();
run(function() {
Expand All @@ -140,3 +149,5 @@ QUnit.test('the DOM element is gone after doing append and remove in a single ru
var viewElem = jQuery('#' + get(view, 'elementId'));
ok(viewElem.length === 0, 'view\'s element doesn\'t exist in DOM');
});

}
9 changes: 4 additions & 5 deletions packages/ember-views/tests/views/view/replace_in_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { get } from 'ember-metal/property_get';
import run from 'ember-metal/run_loop';
import jQuery from 'ember-views/system/jquery';
import EmberView from 'ember-views/views/view';
import ContainerView from 'ember-views/views/container_view';
import compile from 'ember-template-compiler/system/compile';

import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils';
import viewKeyword from 'ember-htmlbars/keywords/view';
Expand Down Expand Up @@ -91,11 +91,10 @@ if (!isEnabled('ember-glimmer')) {
QUnit.module('EmberView - replaceIn() in a view hierarchy', {
setup() {
originalViewKeyword = registerKeyword('view', viewKeyword);
expectDeprecation('Setting `childViews` on a Container is deprecated.');

View = ContainerView.extend({
childViews: ['child'],
child: EmberView.extend({
View = EmberView.extend({
template: compile('{{view view.childView}}'),
childView: EmberView.extend({
elementId: 'child'
})
});
Expand Down

0 comments on commit 2e99a02

Please sign in to comment.