language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
emberjs
ember.js
8b2949cd06e5c30d9028f69b8eb19bf0818e5d52.json
Update CHANGELOG for 2.7.0. [ci skip] (cherry picked from commit 121e3060107773b8161849a7df90319b25026e5f)
CHANGELOG.md
@@ -1,20 +1,17 @@ # Ember Changelog -### 2.7.0-beta.3 (July 5, 2016) +### 2.7.0 (July 25, 2016) +- [#13764](https://github.com/emberjs/ember.js/pull/13764) [BUGFIX] Keep rest positional parameters when nesting contextual components if needed. +- [#13781](https://github.com/emberjs/ember.js/pull/13781) [BUGFIX] Fix NoneLocation#getURL +- [#13797](https://github.com/emberjs/ember.js/pull/13797) [BUGFIX] Ensure didInitAttrs deprecation is stripped in prod. - [#13768](https://github.com/emberjs/ember.js/pull/13768) [BUGFIX] Update route-recognizer to v0.2.0. This addresses a large number of per-existing bugs related to URL encoding. However, in doing so, it might inevitably break existing workarounds in this area. Please refer to the linked pull request for more details. - -### 2.7.0-beta.2 (June 27, 2016) - - [#13634](https://github.com/emberjs/ember.js/pull/13634) [BUGFIX] Fix issues with rerendering blockless and tagless components. - [#13605](https://github.com/emberjs/ember.js/pull/13605) [BUGFIX] Ensure `pauseTest` runs after other async helpers. - [#13655](https://github.com/emberjs/ember.js/pull/13655) [BUGFIX] Make debugging `this._super` much easier (remove manual `.call` / `.apply` optimizations). - [#13672](https://github.com/emberjs/ember.js/pull/13672) [BUGFIX] Fix issue with `this.render` and `this.disconnectOutlet` in routes. - [#13716](https://github.com/emberjs/ember.js/pull/13716) [BUGFIX] Ensure that `Ember.Test.waiters` allows access to configured test waiters. - [#13273](https://github.com/emberjs/ember.js/pull/13273) [BUGFIX] Fix a number of query param related issues reported. - -### 2.7.0-beta.1 (June 8, 2016) - - [#13424](https://github.com/emberjs/ember.js/pull/13424) [DEPRECATE] Deprecate Ember.Binding. See [the deprecation guide](http://emberjs.com/deprecations/v2.x/#toc_ember-binding) for more details. - [#13599](https://github.com/emberjs/ember.js/pull/13599) [FEATURE] Enable `ember-runtime-computed-uniq-by` feature.
false
Other
emberjs
ember.js
fb994035cf79b8f5c515972d41f71fb12c62f273.json
Add dataTransfer test.
packages/ember-glimmer/tests/integration/event-dispatcher-test.js
@@ -4,6 +4,15 @@ import isEnabled from 'ember-metal/features'; import { subscribe, reset } from 'ember-metal/instrumentation'; import run from 'ember-metal/run_loop'; +let canDataTransfer = !!document.createEvent('HTMLEvents').dataTransfer; + +function fireNativeWithDataTransfer(node, type, dataTransfer) { + let event = document.createEvent('HTMLEvents'); + event.initEvent(type, true, true); + event.dataTransfer = dataTransfer; + node.dispatchEvent(event); +} + moduleFor('EventDispatcher', class extends RenderingTest { ['@test events bubble view hierarchy for form elements'](assert) { let receivedEvent; @@ -223,3 +232,23 @@ if (isEnabled('ember-improved-instrumentation')) { } }); } + +if (canDataTransfer) { + moduleFor('EventDispatcher - Event Properties', class extends RenderingTest { + ['@test dataTransfer property is added to drop event'](assert) { + let receivedEvent; + this.registerComponent('x-foo', { + ComponentClass: Component.extend({ + drop(event) { + receivedEvent = event; + } + }) + }); + + this.render(`{{x-foo}}`); + + fireNativeWithDataTransfer(this.$('div')[0], 'drop', 'success'); + assert.equal(receivedEvent.dataTransfer, 'success'); + } + }); +}
true
Other
emberjs
ember.js
fb994035cf79b8f5c515972d41f71fb12c62f273.json
Add dataTransfer test.
packages/ember-views/tests/system/jquery_ext_test.js
@@ -1,70 +0,0 @@ -import run from 'ember-metal/run_loop'; -import EventDispatcher from 'ember-views/system/event_dispatcher'; -import jQuery from 'ember-views/system/jquery'; -import View from 'ember-views/views/view'; - -let view, dispatcher; - -// Adapted from https://github.com/jquery/jquery/blob/f30f7732e7775b6e417c4c22ced7adb2bf76bf89/test/data/testinit.js - -let canDataTransfer = !!document.createEvent('HTMLEvents').dataTransfer; - -function fireNativeWithDataTransfer(node, type, dataTransfer) { - let event = document.createEvent('HTMLEvents'); - event.initEvent(type, true, true); - event.dataTransfer = dataTransfer; - node.dispatchEvent(event); -} - -QUnit.module('EventDispatcher - jQuery integration', { - setup() { - run(() => { - dispatcher = EventDispatcher.create(); - dispatcher.setup(); - }); - }, - - teardown() { - run(() => { - if (view) { view.destroy(); } - dispatcher.destroy(); - }); - } -}); - -if (canDataTransfer) { - QUnit.test('jQuery.event.fix copies over the dataTransfer property', function() { - let originalEvent; - let receivedEvent; - - originalEvent = { - type: 'drop', - dataTransfer: 'success', - target: document.body - }; - - receivedEvent = jQuery.event.fix(originalEvent); - - ok(receivedEvent !== originalEvent, 'attributes are copied to a new event object'); - equal(receivedEvent.dataTransfer, originalEvent.dataTransfer, 'copies dataTransfer property to jQuery event'); - }); - - QUnit.test('drop handler should receive event with dataTransfer property', function() { - let receivedEvent; - let dropCalled = 0; - - view = View.extend({ - drop(evt) { - receivedEvent = evt; - dropCalled++; - } - }).create(); - - run(() => view.append()); - - fireNativeWithDataTransfer(view.$().get(0), 'drop', 'success'); - - equal(dropCalled, 1, 'called drop handler once'); - equal(receivedEvent.dataTransfer, 'success', 'copies dataTransfer property to jQuery event'); - }); -}
true
Other
emberjs
ember.js
6eab29284fcab388d6d9ba4003e7658a4075b6e9.json
Remove odd evented view tests.
packages/ember-views/tests/views/view/evented_test.js
@@ -1,54 +0,0 @@ -import run from 'ember-metal/run_loop'; -import EmberObject from 'ember-runtime/system/object'; -import EmberView from 'ember-views/views/view'; - -let view; - -QUnit.module('EmberView evented helpers', { - teardown() { - run(() => view.destroy()); - } -}); - -QUnit.test('fire should call method sharing event name if it exists on the view', function() { - let eventFired = false; - - view = EmberView.create({ - fireMyEvent() { - this.trigger('myEvent'); - }, - - myEvent() { - eventFired = true; - } - }); - - run(() => view.fireMyEvent()); - - equal(eventFired, true, 'fired the view method sharing the event name'); -}); - -QUnit.test('fire does not require a view method with the same name', function() { - let eventFired = false; - - view = EmberView.create({ - fireMyEvent() { - this.trigger('myEvent'); - } - }); - - let listenObject = EmberObject.create({ - onMyEvent() { - eventFired = true; - } - }); - - view.on('myEvent', listenObject, 'onMyEvent'); - - run(() => view.fireMyEvent()); - - equal(eventFired, true, 'fired the event without a view method sharing its name'); - - run(() => listenObject.destroy()); -}); -
false
Other
emberjs
ember.js
60dddda0f54b1849988c9823ca11d869cf8180fe.json
Remove unneeded classNameBinding tests.
packages/ember-views/tests/views/view/actions_test.js
@@ -1,100 +0,0 @@ -import run from 'ember-metal/run_loop'; -import { Mixin } from 'ember-metal/mixin'; -import Controller from 'ember-runtime/controllers/controller'; -import EmberObject from 'ember-runtime/system/object'; -import View from 'ember-views/views/view'; - -let view; - -QUnit.module('View action handling', { - teardown() { - run(() => { - if (view) { view.destroy(); } - }); - } -}); - -QUnit.test('Action can be handled by a function on actions object', function() { - expect(1); - view = View.extend({ - actions: { - poke() { - ok(true, 'poked'); - } - } - }).create(); - view.send('poke'); -}); - -QUnit.test('A handled action can be bubbled to the target for continued processing', function() { - expect(2); - view = View.extend({ - actions: { - poke() { - ok(true, 'poked 1'); - return true; - } - }, - target: Controller.extend({ - actions: { - poke() { - ok(true, 'poked 2'); - } - } - }).create() - }).create(); - view.send('poke'); -}); - -QUnit.test('Action can be handled by a superclass\' actions object', function() { - expect(4); - - let SuperView = View.extend({ - actions: { - foo() { - ok(true, 'foo'); - }, - bar(msg) { - equal(msg, 'HELLO'); - } - } - }); - - let BarViewMixin = Mixin.create({ - actions: { - bar(msg) { - equal(msg, 'HELLO'); - this._super(msg); - } - } - }); - - let IndexView = SuperView.extend(BarViewMixin, { - actions: { - baz() { - ok(true, 'baz'); - } - } - }); - - view = IndexView.create(); - view.send('foo'); - view.send('bar', 'HELLO'); - view.send('baz'); -}); - -QUnit.test('Actions cannot be provided at create time', function() { - expectAssertion(() => { - view = View.create({ - actions: { - foo() { - ok(true, 'foo'); - } - } - }); - }); - // but should be OK on an object that doesn't mix in Ember.ActionHandler - EmberObject.create({ - actions: ['foo'] - }); -});
true
Other
emberjs
ember.js
60dddda0f54b1849988c9823ca11d869cf8180fe.json
Remove unneeded classNameBinding tests.
packages/ember-views/tests/views/view/class_name_bindings_test.js
@@ -1,36 +0,0 @@ -import run from 'ember-metal/run_loop'; -import { isWatching } from 'ember-metal/watching'; -import EmberView from 'ember-views/views/view'; - -let view; - -QUnit.module('EmberView - Class Name Bindings', { - teardown() { - run(() => view.destroy()); - } -}); - -QUnit.skip('classNameBindings lifecycle test', function() { - run(() => { - view = EmberView.create({ - classNameBindings: ['priority'], - priority: 'high' - }); - }); - - equal(isWatching(view, 'priority'), false); - - run(() => view.createElement()); - - equal(view.$().attr('class'), 'ember-view high'); - equal(isWatching(view, 'priority'), true); - - run(() => { - view.destroyElement(); - view.set('priority', 'low'); - }); - - equal(isWatching(view, 'priority'), false); -}); - -
true
Other
emberjs
ember.js
5de233dec6b4c49770933e60fd76584912961519.json
Migrate additional view tests. Migrate remnants of the following from the `ember-views` package: * `Ember.Checkbox` * `Ember.TextArea` * `Ember.Component` * `TargetActionSupport`
packages/ember-glimmer/tests/integration/components/class-bindings-test.js
@@ -3,8 +3,9 @@ import { Component } from '../../utils/helpers'; import { classes } from '../../utils/test-helpers'; import { set } from 'ember-metal/property_set'; import { strip } from '../../utils/abstract-test-case'; +import computed from 'ember-metal/computed'; -moduleFor('ClassNameBindings intigration', class extends RenderingTest { +moduleFor('ClassNameBindings integration', class extends RenderingTest { ['@test it can have class name bindings']() { let FooBarComponent = Component.extend({ @@ -189,9 +190,22 @@ moduleFor('ClassNameBindings intigration', class extends RenderingTest { this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': classes('ember-view foo') }, content: 'hello' }); } + ['@test using a computed property for classNameBindings triggers an assertion']() { + let FooBarComponent = Component.extend({ + classNameBindings: computed(function() { + return ['isHappy:happy:sad']; + }) + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(() => { + this.render('{{foo-bar}}'); + }, /Only arrays are allowed/); + } }); -moduleFor('ClassBinding intigration', class extends RenderingTest { +moduleFor('ClassBinding integration', class extends RenderingTest { ['@test it should apply classBinding without condition always']() { this.registerComponent('foo-bar', { template: 'hello' });
true
Other
emberjs
ember.js
5de233dec6b4c49770933e60fd76584912961519.json
Migrate additional view tests. Migrate remnants of the following from the `ember-views` package: * `Ember.Checkbox` * `Ember.TextArea` * `Ember.Component` * `TargetActionSupport`
packages/ember-glimmer/tests/integration/components/curly-components-test.js
@@ -10,6 +10,8 @@ import { classes, equalTokens, equalsElement } from '../../utils/test-helpers'; import { htmlSafe } from 'ember-htmlbars/utils/string'; import { computed } from 'ember-metal/computed'; import run from 'ember-metal/run_loop'; +import inject from 'ember-runtime/inject'; +import Service from 'ember-runtime/system/service'; moduleFor('Components test: curly components', class extends RenderingTest { @@ -2317,4 +2319,77 @@ moduleFor('Components test: curly components', class extends RenderingTest { this.assertText('initial value'); } + + ['@test services can be injected into components']() { + let service; + this.registerService('name', Service.extend({ + init() { + this._super(...arguments); + service = this; + }, + last: 'Jackson' + })); + + this.registerComponent('foo-bar', { + ComponentClass: Component.extend({ + name: inject.service() + }), + template: '{{name.last}}' + }); + + this.render('{{foo-bar}}'); + + this.assertText('Jackson'); + + this.runTask(() => this.rerender()); + + this.assertText('Jackson'); + + this.runTask(() => { service.set('last', 'McGuffey'); }); + + this.assertText('McGuffey'); + + this.runTask(() => { service.set('last', 'Jackson'); }); + + this.assertText('Jackson'); + } + + ['@test can access `actions` hash via `_actions` [DEPRECATED]']() { + let component; + + function derp() { } + + this.registerComponent('foo-bar', { + ComponentClass: Component.extend({ + init() { + this._super(...arguments); + component = this; + }, + + actions: { + derp + } + }) + }); + + this.render('{{foo-bar}}'); + + this.assert.strictEqual(component.actions.derp, derp); + + expectDeprecation(() => { + this.assert.strictEqual(component._actions.derp, derp); + }, 'Usage of `_actions` is deprecated, use `actions` instead.'); + } + + ['@test throws if `this._super` is not called from `init`']() { + this.registerComponent('foo-bar', { + ComponentClass: Component.extend({ + init() {} + }) + }); + + expectAssertion(() => { + this.render('{{foo-bar}}'); + }, /You must call `this._super\(...arguments\);` when implementing `init` in a component. Please update .* to call `this._super` from `init`/); + } });
true
Other
emberjs
ember.js
5de233dec6b4c49770933e60fd76584912961519.json
Migrate additional view tests. Migrate remnants of the following from the `ember-views` package: * `Ember.Checkbox` * `Ember.TextArea` * `Ember.Component` * `TargetActionSupport`
packages/ember-glimmer/tests/integration/helpers/text-area-test.js
@@ -1,15 +1,73 @@ import { set } from 'ember-metal/property_set'; import { TextArea } from '../../utils/helpers'; import { RenderingTest, moduleFor } from '../../utils/test-case'; +import assign from 'ember-metal/assign'; +import { classes } from '../../utils/test-helpers'; +import { applyMixins } from '../../utils/abstract-test-case'; class TextAreaRenderingTest extends RenderingTest { constructor() { super(); this.registerComponent('-text-area', { ComponentClass: TextArea }); } + + assertTextArea({ attrs, value } = {}) { + let mergedAttrs = assign({ 'class': classes('ember-view ember-text-area') }, attrs); + this.assertComponentElement(this.firstChild, { tagName: 'textarea', attrs: mergedAttrs }); + + if (value) { + this.assert.strictEqual(value, this.firstChild.value); + } + } + + triggerEvent(type, options = {}) { + let event = document.createEvent('Events'); + event.initEvent(type, true, true); + assign(event, options); + + this.firstChild.dispatchEvent(event); + } } +class BoundTextAreaAttributes { + constructor(cases) { + this.cases = cases; + } + + generate({ attribute, first, second }) { + return { + [`@test ${attribute}`](assert) { + this.render(`{{textarea ${attribute}=value}}`, { + value: first + }); + this.assertTextArea({ attrs: { [attribute]: first } }); + + this.assertStableRerender(); + + this.runTask(() => set(this.context, 'value', second)); + this.assertTextArea({ attrs: { [attribute]: second } }); + + this.runTask(() => set(this.context, 'value', first)); + this.assertTextArea({ attrs: { [attribute]: first } }); + } + }; + } +} + +applyMixins( + TextAreaRenderingTest, + new BoundTextAreaAttributes([ + { attribute: 'placeholder', first: 'Stuff here', second: 'Other stuff' }, + { attribute: 'name', first: 'Stuff here', second: 'Other stuff' }, + { attribute: 'title', first: 'Stuff here', second: 'Other stuff' }, + { attribute: 'maxlength', first: '1', second: '2' }, + { attribute: 'rows', first: '1', second: '2' }, + { attribute: 'cols', first: '1', second: '2' }, + { attribute: 'tabindex', first: '1', second: '2' } + ]) +); + moduleFor('Helpers test: {{textarea}}', class extends TextAreaRenderingTest { ['@test Should insert a textarea']() { @@ -51,15 +109,44 @@ moduleFor('Helpers test: {{textarea}}', class extends TextAreaRenderingTest { this.render('{{textarea value=model.val}}', { model: { val: 'A beautiful day in Seattle' } }); - ok(this.$('textarea').val('A beautiful day in Seattle')); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); this.assertStableRerender(); this.runTask(() => set(this.context, 'model.val', 'Auckland')); - ok(this.$('textarea').val('Auckland')); + this.assertTextArea({ value: 'Auckland' }); this.runTask(() => set(this.context, 'model', { val: 'A beautiful day in Seattle' })); - ok(this.$('textarea').val('A beautiful day in Seattle')); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); } + ['@test should update the value for `cut` / `input` / `change` events']() { + this.render('{{textarea value=model.val}}', { + model: { val: 'A beautiful day in Seattle' } + }); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); + + this.assertStableRerender(); + + this.runTask(() => { + this.firstChild.value = 'Auckland'; + this.triggerEvent('cut'); + }); + this.assertTextArea({ value: 'Auckland' }); + + this.runTask(() => { + this.firstChild.value = 'Hope'; + this.triggerEvent('paste'); + }); + this.assertTextArea({ value: 'Hope' }); + + this.runTask(() => { + this.firstChild.value = 'Boston'; + this.triggerEvent('input'); + }); + this.assertTextArea({ value: 'Boston' }); + + this.runTask(() => set(this.context, 'model', { val: 'A beautiful day in Seattle' })); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); + } });
true
Other
emberjs
ember.js
5de233dec6b4c49770933e60fd76584912961519.json
Migrate additional view tests. Migrate remnants of the following from the `ember-views` package: * `Ember.Checkbox` * `Ember.TextArea` * `Ember.Component` * `TargetActionSupport`
packages/ember-glimmer/tests/utils/abstract-test-case.js
@@ -425,6 +425,10 @@ export class AbstractRenderingTest extends TestCase { } } + registerService(name, klass) { + this.owner.register(`service:${name}`, klass); + } + assertTextNode(node, text) { if (!(node instanceof TextNode)) { throw new Error(`Expecting a text node, but got ${node}`);
true
Other
emberjs
ember.js
5de233dec6b4c49770933e60fd76584912961519.json
Migrate additional view tests. Migrate remnants of the following from the `ember-views` package: * `Ember.Checkbox` * `Ember.TextArea` * `Ember.Component` * `TargetActionSupport`
packages/ember-views/tests/mixins/view_target_action_support_test.js
@@ -1,48 +0,0 @@ -import EmberObject from 'ember-runtime/system/object'; -import View from 'ember-views/views/view'; -import ViewTargetActionSupport from 'ember-views/mixins/view_target_action_support'; - -QUnit.module('ViewTargetActionSupport'); - -QUnit.test('it should return false if no action is specified', function() { - expect(1); - - let view = View.extend(ViewTargetActionSupport).create({ - controller: EmberObject.create() - }); - - ok(false === view.triggerAction(), 'a valid target and action were specified'); -}); - -QUnit.test('it should support actions specified as strings', function() { - expect(2); - - let view = View.extend(ViewTargetActionSupport).create({ - controller: EmberObject.create({ - anEvent() { - ok(true, 'anEvent method was called'); - } - }), - action: 'anEvent' - }); - - ok(true === view.triggerAction(), 'a valid target and action were specified'); -}); - -QUnit.test('it should invoke the send() method on the controller with the view\'s context', function() { - expect(3); - - let view = View.extend(ViewTargetActionSupport, { - controller: EmberObject.create({ - send(evt, context) { - equal(evt, 'anEvent', 'send() method was invoked with correct event name'); - equal(context, view.get('context'), 'send() method was invoked with correct context'); - } - }) - }).create({ - context: {}, - action: 'anEvent' - }); - - ok(true === view.triggerAction(), 'a valid target and action were specified'); -});
true
Other
emberjs
ember.js
5de233dec6b4c49770933e60fd76584912961519.json
Migrate additional view tests. Migrate remnants of the following from the `ember-views` package: * `Ember.Checkbox` * `Ember.TextArea` * `Ember.Component` * `TargetActionSupport`
packages/ember-views/tests/views/checkbox_test.js
@@ -1,139 +0,0 @@ -import Checkbox from 'ember-htmlbars/components/checkbox'; - -import { get } from 'ember-metal/property_get'; -import { set as o_set } from 'ember-metal/property_set'; -import run from 'ember-metal/run_loop'; -import EventDispatcher from 'ember-views/system/event_dispatcher'; - -function set(obj, key, value) { - run(() => o_set(obj, key, value)); -} - -function append() { - run(() => checkboxComponent.appendTo('#qunit-fixture')); -} - -let checkboxComponent, dispatcher; - -QUnit.module('Ember.Checkbox', { - setup() { - dispatcher = EventDispatcher.create(); - dispatcher.setup(); - }, - - teardown() { - run(() => { - dispatcher.destroy(); - checkboxComponent.destroy(); - }); - } -}); - -QUnit.test('should begin disabled if the disabled attribute is true', function() { - checkboxComponent = Checkbox.create({}); - - checkboxComponent.set('disabled', true); - append(); - - ok(checkboxComponent.$().is(':disabled')); -}); - -QUnit.test('should become disabled if the disabled attribute is changed', function() { - checkboxComponent = Checkbox.create({}); - - append(); - ok(checkboxComponent.$().is(':not(:disabled)')); - - run(() => checkboxComponent.set('disabled', true)); - ok(checkboxComponent.$().is(':disabled')); - - run(() => checkboxComponent.set('disabled', false)); - ok(checkboxComponent.$().is(':not(:disabled)')); -}); - -QUnit.test('should begin indeterminate if the indeterminate attribute is true', function() { - checkboxComponent = Checkbox.create({}); - - checkboxComponent.set('indeterminate', true); - append(); - - equal(checkboxComponent.$().prop('indeterminate'), true, 'Checkbox should be indeterminate'); -}); - -QUnit.test('should become indeterminate if the indeterminate attribute is changed', function() { - checkboxComponent = Checkbox.create({}); - - append(); - - equal(checkboxComponent.$().prop('indeterminate'), false, 'Checkbox should not be indeterminate'); - - run(() => checkboxComponent.set('indeterminate', true)); - equal(checkboxComponent.$().prop('indeterminate'), true, 'Checkbox should be indeterminate'); - - run(() => checkboxComponent.set('indeterminate', false)); - equal(checkboxComponent.$().prop('indeterminate'), false, 'Checkbox should not be indeterminate'); -}); - -QUnit.test('should support the tabindex property', function() { - checkboxComponent = Checkbox.create({}); - - run(() => checkboxComponent.set('tabindex', 6)); - append(); - - equal(checkboxComponent.$().prop('tabindex'), '6', 'the initial checkbox tabindex is set in the DOM'); - - run(() => checkboxComponent.set('tabindex', 3)); - equal(checkboxComponent.$().prop('tabindex'), '3', 'the checkbox tabindex changes when it is changed in the component'); -}); - -QUnit.test('checkbox name is updated when setting name property of view', function() { - checkboxComponent = Checkbox.create({}); - - run(() => checkboxComponent.set('name', 'foo')); - append(); - - equal(checkboxComponent.$().attr('name'), 'foo', 'renders checkbox with the name'); - - run(() => checkboxComponent.set('name', 'bar')); - - equal(checkboxComponent.$().attr('name'), 'bar', 'updates checkbox after name changes'); -}); - -QUnit.test('checked property mirrors input value', function() { - checkboxComponent = Checkbox.create({}); - run(() => checkboxComponent.append()); - - equal(get(checkboxComponent, 'checked'), false, 'initially starts with a false value'); - equal(!!checkboxComponent.$().prop('checked'), false, 'the initial checked property is false'); - - set(checkboxComponent, 'checked', true); - - equal(checkboxComponent.$().prop('checked'), true, 'changing the value property changes the DOM'); - - run(() => checkboxComponent.destroyElement()); - run(() => checkboxComponent.append()); - - equal(checkboxComponent.$().prop('checked'), true, 'changing the value property changes the DOM'); - - run(() => checkboxComponent.destroyElement()); - run(() => set(checkboxComponent, 'checked', false)); - run(() => checkboxComponent.append()); - - equal(checkboxComponent.$().prop('checked'), false, 'changing the value property changes the DOM'); -}); - -QUnit.test('checking the checkbox updates the value', function() { - checkboxComponent = Checkbox.create({ checked: true }); - append(); - - equal(get(checkboxComponent, 'checked'), true, 'precond - initially starts with a true value'); - equal(!!checkboxComponent.$().prop('checked'), true, 'precond - the initial checked property is true'); - - // IE fires 'change' event on blur. - checkboxComponent.$()[0].focus(); - checkboxComponent.$()[0].click(); - checkboxComponent.$()[0].blur(); - - equal(!!checkboxComponent.$().prop('checked'), false, 'after clicking a checkbox, the checked property changed'); - equal(get(checkboxComponent, 'checked'), false, 'changing the checkbox causes the view\'s value to get updated'); -});
true
Other
emberjs
ember.js
5de233dec6b4c49770933e60fd76584912961519.json
Migrate additional view tests. Migrate remnants of the following from the `ember-views` package: * `Ember.Checkbox` * `Ember.TextArea` * `Ember.Component` * `TargetActionSupport`
packages/ember-views/tests/views/component_test.js
@@ -1,114 +0,0 @@ -import run from 'ember-metal/run_loop'; -import Service from 'ember-runtime/system/service'; -import inject from 'ember-runtime/inject'; - -import Component from 'ember-templates/component'; - -import buildOwner from 'container/tests/test-helpers/build-owner'; -import computed from 'ember-metal/computed'; - -let component, controller; - -QUnit.module('Ember.Component', { - setup() { - component = Component.create(); - }, - teardown() { - run(() => { - if (component) { component.destroy(); } - if (controller) { controller.destroy(); } - }); - } -}); - -QUnit.test('throws an error if `this._super` is not called from `init`', function() { - let TestComponent = Component.extend({ - init() { } - }); - - expectAssertion(() => { - TestComponent.create(); - }, /You must call `this._super\(...arguments\);` when implementing `init` in a component. Please update .* to call `this._super` from `init`/); -}); - -QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function() { - expect(2); - - component = Component.extend({ - actions: { - foo() { - ok(true, 'called foo action'); - } - } - }).create(); - - expectDeprecation(() => { - component._actions.foo(); - }, 'Usage of `_actions` is deprecated, use `actions` instead.'); -}); - -QUnit.test('Specifying a defaultLayout to a component is deprecated', function() { - expectDeprecation(() => { - Component.extend({ - defaultLayout: 'hum-drum' - }).create(); - }, /Specifying `defaultLayout` to .+ is deprecated\./); -}); - -QUnit.test('should warn if a computed property is used for classNames', function() { - expectAssertion(() => { - Component.extend({ - elementId: 'test', - classNames: computed(function() { - return ['className']; - }) - }).create(); - }, /Only arrays of static class strings.*For dynamic classes/i); -}); - -QUnit.test('should warn if a non-array is used for classNameBindings', function() { - expectAssertion(() => { - Component.extend({ - elementId: 'test', - classNameBindings: computed(function() { - return ['className']; - }) - }).create(); - }, /Only arrays are allowed/i); -}); - -QUnit.module('Ember.Component - injected properties'); - -QUnit.test('services can be injected into components', function() { - let owner = buildOwner(); - - owner.register('component:application', Component.extend({ - profilerService: inject.service('profiler') - })); - - owner.register('service:profiler', Service.extend()); - - let appComponent = owner.lookup('component:application'); - let profilerService = owner.lookup('service:profiler'); - - equal(profilerService, appComponent.get('profilerService'), 'service.profiler is injected'); -}); - -QUnit.module('Ember.Component - subscribed and sent actions trigger errors'); - -QUnit.test('component with target', function() { - expect(2); - - let target = { - send(message, payload) { - equal('foo', message); - equal('baz', payload); - } - }; - - let appComponent = Component.create({ - target: target - }); - - appComponent.send('foo', 'baz'); -});
true
Other
emberjs
ember.js
5de233dec6b4c49770933e60fd76584912961519.json
Migrate additional view tests. Migrate remnants of the following from the `ember-views` package: * `Ember.Checkbox` * `Ember.TextArea` * `Ember.Component` * `TargetActionSupport`
packages/ember-views/tests/views/text_area_test.js
@@ -1,151 +0,0 @@ -import EmberObject from 'ember-runtime/system/object'; -import run from 'ember-metal/run_loop'; -import TextArea from 'ember-htmlbars/components/text_area'; -import { get } from 'ember-metal/property_get'; -import { set as o_set } from 'ember-metal/property_set'; - -let textArea, TestObject; - -function set(object, key, value) { - run(() => o_set(object, key, value)); -} - -function append() { - run(() => textArea.appendTo('#qunit-fixture')); -} - -QUnit.module('TextArea', { - setup() { - TestObject = window.TestObject = EmberObject.create({ - value: null - }); - - textArea = TextArea.create(); - }, - - teardown() { - run(() => textArea.destroy()); - - TestObject = window.TestObject = textArea = null; - } -}); - -QUnit.test('should become disabled if the disabled attribute is true', function() { - textArea.set('disabled', true); - append(); - - ok(textArea.$().is(':disabled')); -}); - -QUnit.test('should become disabled if the disabled attribute is true', function() { - append(); - ok(textArea.$().is(':not(:disabled)')); - - run(() => textArea.set('disabled', true)); - ok(textArea.$().is(':disabled')); - - run(() => textArea.set('disabled', false)); - ok(textArea.$().is(':not(:disabled)')); -}); - -['placeholder', 'name', 'title', 'maxlength', 'rows', 'cols', 'tabindex'].forEach(function(attributeName) { - QUnit.test(`text area ${attributeName} is updated when setting ${attributeName} property of view`, function() { - run(() => { - set(textArea, attributeName, '1'); - textArea.append(); - }); - - equal(textArea.$().attr(attributeName), '1', 'renders text area with ' + attributeName); - - run(() => set(textArea, attributeName, '2')); - - equal(textArea.$().attr(attributeName), '2', `updates text area after ${attributeName} changes`); - }); -}); - -QUnit.test('text area value is updated when setting value property of view', function() { - run(() => { - set(textArea, 'value', 'foo'); - textArea.append(); - }); - - equal(textArea.$().val(), 'foo', 'renders text area with value'); - - run(() => set(textArea, 'value', 'bar')); - - equal(textArea.$().val(), 'bar', 'updates text area after value changes'); -}); - -QUnit.test('value binding works properly for inputs that haven\'t been created', function() { - run(() => { - textArea.destroy(); // destroy existing textarea - - let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + - ' are binding to a global consider using a service instead.'; - - expectDeprecation(() => { - textArea = TextArea.create({ - valueBinding: 'TestObject.value' - }); - }, deprecationMessage); - }); - - equal(get(textArea, 'value'), null, 'precond - default value is null'); - equal(textArea.$(), undefined, 'precond - view doesn\'t have its layer created yet, thus no input element'); - - run(() => set(TestObject, 'value', 'ohai')); - - equal(get(textArea, 'value'), 'ohai', 'value property was properly updated'); - - run(() => textArea.append()); - - equal(get(textArea, 'value'), 'ohai', 'value property remains the same once the view has been appended'); - equal(textArea.$().val(), 'ohai', 'value is reflected in the input element once it is created'); -}); - -['cut', 'paste', 'input'].forEach(eventName => { - QUnit.test('should update the value on ' + eventName + ' events', function() { - run(() => textArea.append()); - - textArea.$().val('new value'); - run(() => { - textArea.trigger(eventName, EmberObject.create({ - type: eventName - })); - }); - - equal(textArea.get('value'), 'new value', 'value property updates on ' + eventName + ' events'); - }); -}); - -QUnit.test('should call the insertNewline method when return key is pressed', function() { - let wasCalled; - let event = EmberObject.create({ - keyCode: 13 - }); - - run(() => textArea.append()); - - textArea.insertNewline = function() { - wasCalled = true; - }; - - textArea.trigger('keyUp', event); - ok(wasCalled, 'invokes insertNewline method'); -}); - -QUnit.test('should call the cancel method when escape key is pressed', function() { - let wasCalled; - let event = EmberObject.create({ - keyCode: 27 - }); - - run(() => textArea.append()); - - textArea.cancel = function() { - wasCalled = true; - }; - - textArea.trigger('keyUp', event); - ok(wasCalled, 'invokes cancel method'); -});
true
Other
emberjs
ember.js
8877657d5e6be741b5d21069847038bf05414448.json
Fix imports to avoid ember-htmlbars.
packages/ember-application/tests/system/visit_test.js
@@ -6,7 +6,7 @@ import Application from 'ember-application/system/application'; import ApplicationInstance from 'ember-application/system/application-instance'; import Route from 'ember-routing/system/route'; import Router from 'ember-routing/system/router'; -import Component from 'ember-htmlbars/component'; +import Component from 'ember-templates/component'; import { compile } from 'ember-template-compiler/tests/utils/helpers'; import jQuery from 'ember-views/system/jquery';
true
Other
emberjs
ember.js
8877657d5e6be741b5d21069847038bf05414448.json
Fix imports to avoid ember-htmlbars.
packages/ember-metal/tests/events_test.js
@@ -1,6 +1,6 @@ import { Mixin } from 'ember-metal/mixin'; import { meta } from 'ember-metal/meta'; -import Component from 'ember-htmlbars/component'; +import Component from 'ember-templates/component'; import { on,
true
Other
emberjs
ember.js
8877657d5e6be741b5d21069847038bf05414448.json
Fix imports to avoid ember-htmlbars.
packages/ember-views/tests/views/component_test.js
@@ -2,7 +2,7 @@ import run from 'ember-metal/run_loop'; import Service from 'ember-runtime/system/service'; import inject from 'ember-runtime/inject'; -import Component from 'ember-htmlbars/component'; +import Component from 'ember-templates/component'; import buildOwner from 'container/tests/test-helpers/build-owner'; import computed from 'ember-metal/computed';
true
Other
emberjs
ember.js
8877657d5e6be741b5d21069847038bf05414448.json
Fix imports to avoid ember-htmlbars.
packages/ember/tests/component_registration_test.js
@@ -3,11 +3,9 @@ import run from 'ember-metal/run_loop'; import Application from 'ember-application/system/application'; import Router from 'ember-routing/system/router'; -import { compile } from 'ember-template-compiler/tests/utils/helpers'; -import helpers from 'ember-htmlbars/helpers'; +import { compile } from 'ember-template-compiler'; import Component from 'ember-templates/component'; import jQuery from 'ember-views/system/jquery'; -import { A as emberA } from 'ember-runtime/system/native_array'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; import isEnabled from 'ember-metal/features'; import require from 'require'; @@ -20,15 +18,10 @@ if (isEnabled('ember-glimmer')) { } let App, appInstance; -let originalHelpers; - -const { keys } = Object; function prepare() { setTemplate('components/expand-it', compile('<p>hello {{yield}}</p>')); setTemplate('application', compile('Hello world {{#expand-it}}world{{/expand-it}}')); - - originalHelpers = emberA(keys(helpers)); } function cleanup() { @@ -40,28 +33,10 @@ function cleanup() { App = appInstance = null; } finally { setTemplates({}); - cleanupHelpers(); } }); } -function cleanupHelpers() { - let included; - - keys(helpers). - forEach(name => { - if (isEnabled('ember-runtime-enumerable-includes')) { - included = originalHelpers.includes(name); - } else { - included = originalHelpers.contains(name); - } - - if (!included) { - delete helpers[name]; - } - }); -} - QUnit.module('Application Lifecycle - Component Registration', { setup: prepare, teardown: cleanup @@ -117,7 +92,6 @@ QUnit.test('Late-registered components can be rendered with custom `layout` prop }); equal(jQuery('#wrapper').text(), 'there goes watch him as he GOES', 'The component is composed correctly'); - ok(!helpers['my-hero'], 'Component wasn\'t saved to global helpers hash'); }); QUnit.test('Late-registered components can be rendered with template registered on the container', function() { @@ -129,7 +103,6 @@ QUnit.test('Late-registered components can be rendered with template registered }); equal(jQuery('#wrapper').text(), 'hello world funkytowny-funkytowny!!!', 'The component is composed correctly'); - ok(!helpers['sally-rutherford'], 'Component wasn\'t saved to global helpers hash'); }); QUnit.test('Late-registered components can be rendered with ONLY the template registered on the container', function() { @@ -140,7 +113,6 @@ QUnit.test('Late-registered components can be rendered with ONLY the template re }); equal(jQuery('#wrapper').text(), 'hello world goodfreakingTIMES-goodfreakingTIMES!!!', 'The component is composed correctly'); - ok(!helpers['borf-snorlax'], 'Component wasn\'t saved to global helpers hash'); }); QUnit.test('Assigning layoutName to a component should setup the template as a layout', function() {
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-application/lib/system/application.js
@@ -12,7 +12,6 @@ import Namespace, { } from 'ember-runtime/system/namespace'; import { runLoadHooks } from 'ember-runtime/system/lazy_load'; import run from 'ember-metal/run_loop'; -import EmberView from 'ember-views/views/view'; import EventDispatcher from 'ember-views/system/event_dispatcher'; import jQuery from 'ember-views/system/jquery'; import Route from 'ember-routing/system/route'; @@ -403,10 +402,10 @@ const Application = Engine.extend({ This is orthogonal to autoboot: the deprecated instance needs to be created at Application construction (not boot) time to expose - App.__container__ and the global Ember.View.views registry. If - autoboot sees that this instance exists, it will continue booting - it to avoid doing unncessary work (as opposed to building a new - instance at boot time), but they are otherwise unrelated. + App.__container__. If autoboot sees that this instance exists, + it will continue booting it to avoid doing unncessary work (as + opposed to building a new instance at boot time), but they are + otherwise unrelated. @private @method _buildDeprecatedInstance @@ -419,10 +418,6 @@ const Application = Engine.extend({ // on App that rely on a single, default instance. this.__deprecatedInstance__ = instance; this.__container__ = instance.__container__; - - // For the default instance only, set the view registry to the global - // Ember.View.views hash for backwards-compatibility. - EmberView.views = instance.lookup('-view-registry:main'); }, /**
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-application/lib/system/engine.js
@@ -487,6 +487,8 @@ function commonSetupRegistry(registry) { registry.injection('service:-dom-helper', 'document', 'service:-document'); registry.injection('view', '_viewRegistry', '-view-registry:main'); + registry.injection('renderer', '_viewRegistry', '-view-registry:main'); + registry.injection('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); registry.injection('route', '_topLevelViewTemplate', 'template:-outlet');
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-glimmer/lib/component.js
@@ -7,7 +7,6 @@ import AriaRoleSupport from 'ember-views/mixins/aria_role_support'; import ViewMixin from 'ember-views/mixins/view_support'; import ActionSupport from 'ember-views/mixins/action_support'; import TargetActionSupport from 'ember-runtime/mixins/target_action_support'; -import EmberView from 'ember-views/views/view'; import symbol from 'ember-metal/symbol'; import EmptyObject from 'ember-metal/empty_object'; import { get } from 'ember-metal/property_get'; @@ -48,7 +47,6 @@ const Component = CoreView.extend( init() { this._super(...arguments); - this._viewRegistry = this._viewRegistry || EmberView.views; this[DIRTY_TAG] = new DirtyableTag(); this[ROOT_REF] = null; this[REFS] = new EmptyObject();
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-glimmer/lib/renderer.js
@@ -2,6 +2,8 @@ import { RootReference } from './utils/references'; import run from 'ember-metal/run_loop'; import { setHasViews } from 'ember-metal/tags'; import { CURRENT_TAG, UNDEFINED_REFERENCE } from 'glimmer-reference'; +import fallbackViewRegistry from 'ember-views/compat/fallback-view-registry'; +import { assert } from 'ember-metal/debug'; const { backburner } = run; @@ -115,12 +117,13 @@ class Scheduler { } class Renderer { - constructor({ dom, env, destinedForDOM = false }) { + constructor({ dom, env, _viewRegistry, destinedForDOM = false }) { this._root = null; this._dom = dom; this._env = env; this._destinedForDOM = destinedForDOM; this._scheduler = new Scheduler(); + this._viewRegistry = _viewRegistry || fallbackViewRegistry; } destroy() { @@ -209,16 +212,25 @@ class Renderer { // TODO: Implement this // throw new Error('Something you did caused a view to re-render after it rendered but before it was inserted into the DOM.'); } + + _register(view) { + assert('Attempted to register a view with an id already in use: ' + view.elementId, !this._viewRegistry[this.elementId]); + this._viewRegistry[view.elementId] = view; + } + + _unregister(view) { + delete this._viewRegistry[this.elementId]; + } } export const InertRenderer = { - create({ dom, env }) { - return new Renderer({ dom, env, destinedForDOM: false }); + create({ dom, env, _viewRegistry }) { + return new Renderer({ dom, env, _viewRegistry, destinedForDOM: false }); } }; export const InteractiveRenderer = { - create({ dom, env }) { - return new Renderer({ dom, env, destinedForDOM: true }); + create({ dom, env, _viewRegistry }) { + return new Renderer({ dom, env, _viewRegistry, destinedForDOM: true }); } };
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-glimmer/tests/integration/components/curly-components-test.js
@@ -1968,54 +1968,6 @@ moduleFor('Components test: curly components', class extends RenderingTest { assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); } - ['@htmlbars component should receive the viewRegistry from the parentView'](assert) { - let outer, innerTemplate, innerLayout; - - let viewRegistry = {}; - - this.registerComponent('x-outer', { - ComponentClass: Component.extend({ - init() { - this._super(...arguments); - outer = this; - } - }), - template: '{{x-inner-in-layout}}{{yield}}' - }); - - this.registerComponent('x-inner-in-template', { - ComponentClass: Component.extend({ - init() { - this._super(...arguments); - innerTemplate = this; - } - }) - }); - - this.registerComponent('x-inner-in-layout', { - ComponentClass: Component.extend({ - init() { - this._super(...arguments); - innerLayout = this; - } - }) - }); - - this.render('{{#x-outer}}{{x-inner-in-template}}{{/x-outer}}', { - _viewRegistry: viewRegistry - }); - - assert.equal(innerTemplate._viewRegistry, viewRegistry); - assert.equal(innerLayout._viewRegistry, viewRegistry); - assert.equal(outer._viewRegistry, viewRegistry); - - this.runTask(() => this.rerender()); - - assert.equal(innerTemplate._viewRegistry, viewRegistry); - assert.equal(innerLayout._viewRegistry, viewRegistry); - assert.equal(outer._viewRegistry, viewRegistry); - } - ['@htmlbars component should rerender when a property is changed during children\'s rendering'](assert) { expectDeprecation(/modified value twice in a single render/);
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-glimmer/tests/utils/abstract-test-case.js
@@ -319,6 +319,7 @@ export class AbstractRenderingTest extends TestCase { this.component = null; owner.register('event_dispatcher:main', EventDispatcher); + owner.inject('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); owner.lookup('event_dispatcher:main').setup(this.getCustomDispatcherEvents(), owner.element); }
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-glimmer/tests/utils/helpers.js
@@ -23,6 +23,9 @@ export function buildOwner(options) { owner.inject('service:-dom-helper', 'document', 'service:-document'); owner.inject('component', 'renderer', 'renderer:-dom'); owner.inject('template', 'env', 'service:-glimmer-environment'); + + owner.register('-view-registry:main', { create() { return {}; } }); + owner.inject('renderer', '_viewRegistry', '-view-registry:main'); + return owner; } -
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-htmlbars/lib/node-managers/component-node-manager.js
@@ -169,7 +169,6 @@ export function createComponent(_component, props, renderNode, env, attrs = {}) setOwner(props, env.owner); props.renderer = props.parentView ? props.parentView.renderer : env.owner.lookup('renderer:-dom'); - props._viewRegistry = props.parentView ? props.parentView._viewRegistry : env.owner.lookup('-view-registry:main'); let component = _component.create(props);
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-htmlbars/lib/node-managers/view-node-manager.js
@@ -191,7 +191,6 @@ export function createOrUpdateComponent(component, options, createOptions, rende setOwner(props, owner); props.renderer = options.parentView ? options.parentView.renderer : owner && owner.lookup('renderer:-dom'); - props._viewRegistry = options.parentView ? options.parentView._viewRegistry : owner && owner.lookup('-view-registry:main'); if (proto.controller !== defaultController || hasSuppliedController) { delete props._context;
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-htmlbars/lib/renderer.js
@@ -7,8 +7,10 @@ import buildComponentTemplate from 'ember-htmlbars/system/build-component-templa import { environment } from 'ember-environment'; import { internal } from 'htmlbars-runtime'; import { renderHTMLBarsBlock } from 'ember-htmlbars/system/render-view'; +import fallbackViewRegistry from 'ember-views/compat/fallback-view-registry'; +import { assert } from 'ember-metal/debug'; -export function Renderer(domHelper, { destinedForDOM } = {}) { +export function Renderer(domHelper, { destinedForDOM, _viewRegistry } = {}) { this._dom = domHelper; // This flag indicates whether the resulting rendered element will be @@ -20,6 +22,8 @@ export function Renderer(domHelper, { destinedForDOM } = {}) { this._destinedForDOM = destinedForDOM === undefined ? environment.hasDOM : destinedForDOM; + + this._viewRegistry = _viewRegistry || fallbackViewRegistry; } Renderer.prototype.prerenderTopLevelView = @@ -281,14 +285,24 @@ Renderer.prototype.didDestroyElement = function (view) { } }; + +Renderer.prototype._register = function Renderer_register(view) { + assert('Attempted to register a view with an id already in use: ' + view.elementId, !this._viewRegistry[this.elementId]); + this._viewRegistry[view.elementId] = view; +}; + +Renderer.prototype._unregister = function Renderer_unregister(view) { + delete this._viewRegistry[this.elementId]; +}; + export const InertRenderer = { - create({ dom }) { - return new Renderer(dom, { destinedForDOM: false }); + create({ dom, _viewRegistry }) { + return new Renderer(dom, { destinedForDOM: false, _viewRegistry }); } }; export const InteractiveRenderer = { - create({ dom }) { - return new Renderer(dom, { destinedForDOM: true }); + create({ dom, _viewRegistry }) { + return new Renderer(dom, { destinedForDOM: true, _viewRegistry }); } };
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-htmlbars/tests/utils/helpers.js
@@ -23,5 +23,11 @@ export function buildOwner(options) { setupApplicationRegistry(owner.__registry__); owner.register('service:-htmlbars-environment', new Environment(), { instantiate: false }); owner.inject('service:-htmlbars-environment', 'dom', 'service:-dom-helper'); + + owner.register('-view-registry:main', { create() { return {}; } }); + owner.inject('renderer', '_viewRegistry', '-view-registry:main'); + owner.inject('renderer', 'dom', 'service:-dom-helper'); + owner.inject('component', 'renderer', 'renderer:-dom'); + return owner; }
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-views/lib/compat/fallback-view-registry.js
@@ -0,0 +1,3 @@ +import dict from 'ember-metal/dictionary'; + +export default dict(null);
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-views/lib/mixins/view_support.js
@@ -553,32 +553,5 @@ export default Mixin.create({ */ handleEvent(eventName, evt) { return this._currentState.handleEvent(this, eventName, evt); - }, - - /** - Registers the view in the view registry, keyed on the view's `elementId`. - This is used by the EventDispatcher to locate the view in response to - events. - - This method should only be called once the view has been inserted into the - DOM. - - @method _register - @private - */ - _register() { - assert('Attempted to register a view with an id already in use: ' + this.elementId, !this._viewRegistry[this.elementId]); - this._viewRegistry[this.elementId] = this; - }, - - /** - Removes the view from the view registry. This should be called when the - view is removed from DOM. - - @method _unregister - @private - */ - _unregister() { - delete this._viewRegistry[this.elementId]; } });
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-views/lib/system/event_dispatcher.js
@@ -11,10 +11,10 @@ import run from 'ember-metal/run_loop'; import EmberObject from 'ember-runtime/system/object'; import jQuery from 'ember-views/system/jquery'; import ActionManager from 'ember-views/system/action_manager'; -import View from 'ember-views/views/view'; import assign from 'ember-metal/assign'; import { getOwner } from 'container/owner'; import { environment } from 'ember-environment'; +import fallbackViewRegistry from 'ember-views/compat/fallback-view-registry'; const ROOT_ELEMENT_CLASS = 'ember-application'; const ROOT_ELEMENT_SELECTOR = '.' + ROOT_ELEMENT_CLASS; @@ -199,7 +199,7 @@ export default EmberObject.extend({ let self = this; let owner = getOwner(this); - let viewRegistry = owner && owner.lookup('-view-registry:main') || View.views; + let viewRegistry = owner && owner.lookup('-view-registry:main') || fallbackViewRegistry; if (eventName === null) { return;
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-views/lib/views/states/in_dom.js
@@ -16,7 +16,7 @@ assign(inDOM, { // Register the view for event handling. This hash is used by // Ember.EventDispatcher to dispatch incoming events. if (view.tagName !== '') { - view._register(); + view.renderer._register(view); } runInDebug(() => { @@ -28,7 +28,7 @@ assign(inDOM, { exit(view) { if (view.tagName !== '') { - view._unregister(); + view.renderer._unregister(view); } } });
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-views/lib/views/view.js
@@ -515,14 +515,6 @@ var View = CoreView.extend( ViewMixin, { attributeBindings: ['ariaRole:role'], - init() { - this._super(...arguments); - - if (!this._viewRegistry) { - this._viewRegistry = View.views; - } - }, - /** Given a property name, returns a dasherized version of that property name if the property evaluates to a non-falsy value. @@ -568,18 +560,6 @@ var View = CoreView.extend( // once the view has been inserted into the DOM, legal manipulations // are done on the DOM element. -View.reopenClass({ - /** - Global views hash - - @property views - @static - @type Object - @private - */ - views: {} -}); - export default View; export { ViewChildViewsSupport, ViewStateSupport, ClassNamesSupport };
true
Other
emberjs
ember.js
2a233df8c6aa387898299d79dd4b2965b4266015.json
Use the renderer to manage the view registry. * Remove usage of `Ember.View.views`. This has not been exposed since 1.x. * Use the renderer to update view registry.
packages/ember-views/tests/views/view/append_to_test.js
@@ -106,7 +106,6 @@ QUnit.test('remove removes an element from the DOM', function() { run(() => view.destroyElement()); ok(jQuery('#' + get(view, 'elementId')).length === 0, 'remove removes an element from the DOM'); - ok(EmberView.views[get(view, 'elementId')] === undefined, 'remove does not remove the view from the view hash'); ok(!get(view, 'element'), 'remove nulls out the element'); equal(willDestroyCalled, 1, 'the willDestroyElement hook was called once'); }); @@ -129,7 +128,6 @@ QUnit.test('destroy more forcibly removes the view', function() { run(() => view.destroy()); ok(jQuery('#' + get(view, 'elementId')).length === 0, 'destroy removes an element from the DOM'); - ok(EmberView.views[get(view, 'elementId')] === undefined, 'destroy removes a view from the global views hash'); equal(get(view, 'isDestroyed'), true, 'the view is marked as destroyed'); ok(!get(view, 'element'), 'the view no longer has an element'); equal(willDestroyCalled, 1, 'the willDestroyElement hook was called once');
true
Other
emberjs
ember.js
a642ec941ec323be72e0288e4a369850555d76df.json
Update emberjs-build to fix dist output. * Ensures that `ember-templates` is available in `ember-template-compiler` * Removes `ember-template-compiler` (and related packages) from `ember.debug.js` and `ember.prod.js`.
lib/packages.js
@@ -14,11 +14,13 @@ var packages = { 'ember-testing': { trees: null, requirements: ['ember-application', 'ember-routing'], testing: true }, 'ember-template-compiler': { trees: null, + templateCompilerOnly: true, requirements: ['ember-metal', 'ember-environment', 'ember-console', 'ember-htmlbars-template-compiler', 'ember-templates'], templateCompilerVendor: ['simple-html-tokenizer'] }, 'ember-htmlbars-template-compiler': { trees: null, + templateCompilerOnly: true, requirements: [], vendorRequirements: ['htmlbars-runtime'], templateCompilerVendor: ['htmlbars-runtime', 'htmlbars-util', 'htmlbars-compiler', 'htmlbars-syntax', 'htmlbars-test-helpers', 'morph-range', 'backburner'] @@ -56,6 +58,7 @@ if (glimmerStatus === null || glimmerStatus === true) { packages['ember-glimmer-template-compiler'] = { trees: null, + templateCompilerOnly: true, requirements: [], templateCompilerVendor: [ 'glimmer-wire-format',
true
Other
emberjs
ember.js
a642ec941ec323be72e0288e4a369850555d76df.json
Update emberjs-build to fix dist output. * Ensures that `ember-templates` is available in `ember-template-compiler` * Removes `ember-template-compiler` (and related packages) from `ember.debug.js` and `ember.prod.js`.
package.json
@@ -33,7 +33,7 @@ "ember-cli-sauce": "^1.4.2", "ember-cli-yuidoc": "0.8.4", "ember-publisher": "0.0.7", - "emberjs-build": "0.10.0", + "emberjs-build": "0.11.0", "express": "^4.5.0", "finalhandler": "^0.4.0", "github": "^0.2.3",
true
Other
emberjs
ember.js
73060aa0bcd1251198cbafdf6a4b256c17f1a41d.json
Remove broken `require('jquery')`. Originally [this line](https://github.com/emberjs/ember.js/blob/3ab8ba2af6551a174f3b91ac9b202bc9f27c09a4/packages/ember-views/lib/system/jquery.js#L8) was checking for a global `require`, but as of https://github.com/emberjs/ember.js/pull/13440 we changed to import or own internal `require`. At the moment, that `require('jquery')` (using our internal loader's version of `require`) will never find a module named `jquery` and will error. I believe we should just remove this guard/check completely. We can always reevaluate if folks still need this for something...
packages/ember-views/lib/system/jquery.js
@@ -1,13 +1,9 @@ import { context, environment } from 'ember-environment'; -import require from 'require'; let jQuery; if (environment.hasDOM) { jQuery = context.imports.jQuery; - if (!jQuery && typeof require === 'function') { - jQuery = require('jquery'); - } if (jQuery) { if (jQuery.event.addProp) {
false
Other
emberjs
ember.js
c47b1768f030d8959e95874a7abb49e06a36760a.json
Add container to yuidoc.json Fixes #13734
yuidoc.json
@@ -15,6 +15,7 @@ "packages/ember-application/lib", "packages/ember-testing/lib", "packages/ember-extension-support/lib", + "packages/container/lib", "bower_components/rsvp/lib", "bower_components/router.js/lib/router" ],
false
Other
emberjs
ember.js
fcd04520ecb8c0bb6b8c2e10a6198436bd5ac36a.json
Implement local lookup for helpers
package.json
@@ -37,7 +37,7 @@ "express": "^4.5.0", "finalhandler": "^0.4.0", "github": "^0.2.3", - "glimmer-engine": "tildeio/glimmer#256f044", + "glimmer-engine": "tildeio/glimmer#2caafc3", "glob": "^5.0.13", "htmlbars": "0.14.24", "mocha": "^2.4.5",
true
Other
emberjs
ember.js
fcd04520ecb8c0bb6b8c2e10a6198436bd5ac36a.json
Implement local lookup for helpers
packages/ember-glimmer/lib/environment.js
@@ -212,12 +212,12 @@ export default class Environment extends GlimmerEnvironment { return generateBuiltInSyntax(statement, (path) => this.getComponentDefinition([path], parentMeta)); } - assert(`Could not find component named "${key}" (no component or template with that name was found)`, !isBlock || this.hasHelper(key)); + assert(`Could not find component named "${key}" (no component or template with that name was found)`, !isBlock || this.hasHelper(key, parentMeta)); } - assert(`Helpers may not be used in the block form, for example {{#${key}}}{{/${key}}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (${key})}}{{/if}}.`, !isBlock || !this.hasHelper(key)); + assert(`Helpers may not be used in the block form, for example {{#${key}}}{{/${key}}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (${key})}}{{/if}}.`, !isBlock || !this.hasHelper(key, parentMeta)); - assert(`Helpers may not be used in the element form.`, !nativeSyntax && key && this.hasHelper(key) ? !isModifier : true); + assert(`Helpers may not be used in the element form.`, !nativeSyntax && key && this.hasHelper(key, parentMeta) ? !isModifier : true); } hasComponentDefinition() { @@ -257,12 +257,18 @@ export default class Environment extends GlimmerEnvironment { } } - hasHelper(name) { - return !!builtInHelpers[name[0]] || this.owner.hasRegistration(`helper:${name}`); + hasHelper(name, parentMeta) { + let options = parentMeta && { source: `template:${parentMeta.moduleName}` } || {}; + return !!builtInHelpers[name[0]] || + this.owner.hasRegistration(`helper:${name}`, options) || + this.owner.hasRegistration(`helper:${name}`); } - lookupHelper(name) { - let helper = builtInHelpers[name[0]] || this.owner.lookup(`helper:${name}`); + lookupHelper(name, parentMeta) { + let options = parentMeta && { source: `template:${parentMeta.moduleName}` } || {}; + let helper = builtInHelpers[name[0]] || + this.owner.lookup(`helper:${name}`, options) || + this.owner.lookup(`helper:${name}`); // TODO: try to unify this into a consistent protocol to avoid wasteful closure allocations if (helper.isInternalHelper) { return (args) => helper.toReference(args);
true
Other
emberjs
ember.js
fcd04520ecb8c0bb6b8c2e10a6198436bd5ac36a.json
Implement local lookup for helpers
packages/ember-glimmer/tests/integration/components/local-lookup-test.js
@@ -104,7 +104,7 @@ moduleFor('Components test: local lookup', class extends RenderingTest { this.assertText('yall finished or yall done?'); } - ['@htmlbars it can lookup a local helper']() { + ['@test it can lookup a local helper']() { this.registerHelper('x-outer/x-helper', () => { return 'Who dis?'; });
true
Other
emberjs
ember.js
0ffcf8209be2e11b8f2fa5c4b5b7acc11a9fbc45.json
Update CHANGELOG for 2.7 beta 3 (cherry picked from commit b27e3a1ef2ead96693097617bd9ce92aa125cf2f)
CHANGELOG.md
@@ -1,5 +1,9 @@ # Ember Changelog +### 2.7.0-beta.3 (July 5, 2016) + +- [#13768](https://github.com/emberjs/ember.js/pull/13768) [BUGFIX] Update route-recognizer to v0.2.0. This addresses a large number of per-existing bugs related to URL encoding. However, in doing so, it might inevitably break existing workarounds in this area. Please refer to the linked pull request for more details. + ### 2.7.0-beta.2 (June 27, 2016) - [#13634](https://github.com/emberjs/ember.js/pull/13634) [BUGFIX] Fix issues with rerendering blockless and tagless components.
false
Other
emberjs
ember.js
9228bb85f7c2237b4699f1c9e810426d29ea5188.json
Add tests for view cleanup/destruction. * [Glimmer] Ensure `.parentView` is present at creation. * Add tests for `.parentView` and `.element` in each lifecycle hook. * Remove duplicated `parentView` manipulation (this is now done as part of `renderer.remove`). * Add test ensuring `willDestroyElement` is called for inverse. * Ensure element in DOM during willDestroyElement.
packages/ember-glimmer/lib/syntax/curly-component.js
@@ -72,6 +72,7 @@ class CurlyComponentManager { aliasIdToElementId(args, props); + props.parentView = parentView; props.renderer = parentView.renderer; props[HAS_BLOCK] = hasBlock;
true
Other
emberjs
ember.js
9228bb85f7c2237b4699f1c9e810426d29ea5188.json
Add tests for view cleanup/destruction. * [Glimmer] Ensure `.parentView` is present at creation. * Add tests for `.parentView` and `.element` in each lifecycle hook. * Remove duplicated `parentView` manipulation (this is now done as part of `renderer.remove`). * Add test ensuring `willDestroyElement` is called for inverse. * Ensure element in DOM during willDestroyElement.
packages/ember-glimmer/tests/integration/components/dynamic-components-test.js
@@ -310,10 +310,15 @@ moduleFor('Components test: dynamic components', class extends RenderingTest { ['@test component helper destroys underlying component when it is swapped out'](assert) { let destroyed = { 'foo-bar': 0, 'foo-bar-baz': 0 }; + let testContext = this; this.registerComponent('foo-bar', { template: 'hello from foo-bar', ComponentClass: Component.extend({ + willDestroyElement() { + assert.equal(testContext.$(`#${this.elementId}`).length, 1, 'element is still attached to the document'); + }, + willDestroy() { this._super(); destroyed['foo-bar']++;
true
Other
emberjs
ember.js
9228bb85f7c2237b4699f1c9e810426d29ea5188.json
Add tests for view cleanup/destruction. * [Glimmer] Ensure `.parentView` is present at creation. * Add tests for `.parentView` and `.element` in each lifecycle hook. * Remove duplicated `parentView` manipulation (this is now done as part of `renderer.remove`). * Add test ensuring `willDestroyElement` is called for inverse. * Ensure element in DOM during willDestroyElement.
packages/ember-glimmer/tests/integration/components/life-cycle-test.js
@@ -8,16 +8,15 @@ class LifeCycleHooksTest extends RenderingTest { super(); this.hooks = []; this.components = {}; + this.teardownAssertions = []; } teardown() { - super(); - this.assertHooks( - 'destroy', - ['the-top', 'willDestroyElement'], - ['the-middle', 'willDestroyElement'], - ['the-bottom', 'willDestroyElement'] - ); + super.teardown(); + + for (let i = 0; i < this.teardownAssertions.length; i++) { + this.teardownAssertions[i](); + } } /* abstract */ @@ -51,49 +50,90 @@ class LifeCycleHooksTest extends RenderingTest { this.hooks.push(hook(name, hookName, args)); }; + let assertParentView = (hookName, instance) => { + if (!instance.parentView) { + this.assert.ok(false, `parentView should be present in ${hookName}`); + } + }; + + let assertElement = (hookName, instance) => { + if (instance.tagName === '') { return; } + + if (!instance.element) { + this.assert.ok(false, `element property should be present on ${instance} during ${hookName}`); + } + + let inDOM = this.$(`#${instance.elementId}`)[0]; + if (!inDOM) { + this.assert.ok(false, `element for ${instance} should be in the DOM during ${hookName}`); + } + }; + + let assertNoElement = (hookName, instance) => { + if (instance.element) { + this.assert.ok(false, `element should not be present in ${hookName}`); + } + }; + let ComponentClass = this.ComponentClass.extend({ init() { expectDeprecation(() => { this._super(...arguments); }, /didInitAttrs called/); pushHook('init'); pushComponent(this); + assertParentView('init', this); + assertNoElement('init', this); }, didInitAttrs(options) { pushHook('didInitAttrs', options); + assertParentView('didInitAttrs', this); + assertNoElement('didInitAttrs', this); }, didUpdateAttrs(options) { pushHook('didUpdateAttrs', options); + assertParentView('didUpdateAttrs', this); }, willUpdate(options) { pushHook('willUpdate', options); + assertParentView('willUpdate', this); }, didReceiveAttrs(options) { pushHook('didReceiveAttrs', options); + assertParentView('didReceiveAttrs', this); }, willRender() { pushHook('willRender'); + assertParentView('willRender', this); }, didRender() { pushHook('didRender'); + assertParentView('didRender', this); + assertElement('didRender', this); }, didInsertElement() { pushHook('didInsertElement'); + assertParentView('didInsertElement', this); + assertElement('didInsertElement', this); }, didUpdate(options) { pushHook('didUpdate', options); + assertParentView('didUpdate', this); + assertElement('didUpdate', this); }, willDestroyElement() { pushHook('willDestroyElement'); + assertParentView('willDestroyElement', this); + assertElement('willDestroyElement', this); } }); @@ -341,6 +381,15 @@ class LifeCycleHooksTest extends RenderingTest { ['the-top', 'didRender'] ); + + this.teardownAssertions.push(() => { + this.assertHooks( + 'destroy', + ['the-top', 'willDestroyElement'], + ['the-middle', 'willDestroyElement'], + ['the-bottom', 'willDestroyElement'] + ); + }); } ['@test passing values through attrs causes lifecycle hooks to fire if the attribute values have changed']() { @@ -504,8 +553,105 @@ class LifeCycleHooksTest extends RenderingTest { } else { this.assertHooks('after no-op rernder (root)'); } + + this.teardownAssertions.push(() => { + this.assertHooks( + 'destroy', + ['the-top', 'willDestroyElement'], + ['the-middle', 'willDestroyElement'], + ['the-bottom', 'willDestroyElement'] + ); + }); } + ['@test components rendered from `{{each}}` have correct life-cycle hooks to be called']() { + let { invoke } = this.boundHelpers; + + this.registerComponent('an-item', { template: strip` + <div>Item: {{count}}</div> + ` }); + + this.registerComponent('no-items', { template: strip` + <div>Nothing to see here</div> + ` }); + + this.render(strip` + {{#each items as |item|}} + ${invoke('an-item', { count: expr('item') })} + {{else}} + ${invoke('no-items')} + {{/each}} + `, { + items: [1, 2, 3, 4, 5] + }); + + this.assertText('Item: 1Item: 2Item: 3Item: 4Item: 5'); + + let initialHooks = (count) => { + return [ + ['an-item', 'init'], + ['an-item', 'didInitAttrs', { attrs: { count } }], + ['an-item', 'didReceiveAttrs', { newAttrs: { count } }], + ['an-item', 'willRender'] + ]; + }; + + let initialAfterRenderHooks = (count) => { + return [ + ['an-item', 'didInsertElement'], + ['an-item', 'didRender'] + ]; + }; + + this.assertHooks( + + 'after initial render', + + // Sync hooks + ...initialHooks(1), + ...initialHooks(2), + ...initialHooks(3), + ...initialHooks(4), + ...initialHooks(5), + + // Async hooks + ...initialAfterRenderHooks(5), + ...initialAfterRenderHooks(4), + ...initialAfterRenderHooks(3), + ...initialAfterRenderHooks(2), + ...initialAfterRenderHooks(1) + ); + + this.runTask(() => set(this.context, 'items', [])); + + this.assertText('Nothing to see here'); + + this.assertHooks( + 'reset to empty array', + + ['an-item', 'willDestroyElement'], + ['an-item', 'willDestroyElement'], + ['an-item', 'willDestroyElement'], + ['an-item', 'willDestroyElement'], + ['an-item', 'willDestroyElement'], + + ['no-items', 'init'], + ['no-items', 'didInitAttrs', { attrs: { } }], + ['no-items', 'didReceiveAttrs', { newAttrs: { } }], + ['no-items', 'willRender'], + + ['no-items', 'didInsertElement'], + ['no-items', 'didRender'] + ); + + this.teardownAssertions.push(() => { + this.assertHooks( + 'destroy', + + ['no-items', 'willDestroyElement'] + ); + }); + } } moduleFor('Components test: lifecycle hooks (curly components)', class extends LifeCycleHooksTest {
true
Other
emberjs
ember.js
9228bb85f7c2237b4699f1c9e810426d29ea5188.json
Add tests for view cleanup/destruction. * [Glimmer] Ensure `.parentView` is present at creation. * Add tests for `.parentView` and `.element` in each lifecycle hook. * Remove duplicated `parentView` manipulation (this is now done as part of `renderer.remove`). * Add test ensuring `willDestroyElement` is called for inverse. * Ensure element in DOM during willDestroyElement.
packages/ember-htmlbars/lib/morphs/morph.js
@@ -35,15 +35,6 @@ proto.addDestruction = function(toDestroy) { }; proto.cleanup = function() { - let view = this.emberView; - - if (view) { - let parentView = view.parentView; - if (parentView && view.ownerView._destroyingSubtreeForView === parentView) { - parentView.removeChild(view); - } - } - let toDestroy = this.emberToDestroy; if (toDestroy) {
true
Other
emberjs
ember.js
9e807f3e119f16eece09de5600d02574a5e5886f.json
Add 2.7.0-beta.2 to CHANGELOG. [ci skip]
CHANGELOG.md
@@ -1,5 +1,14 @@ # Ember Changelog +### 2.7.0-beta.2 (June 27, 2016) + +- [#13634](https://github.com/emberjs/ember.js/pull/13634) [BUGFIX] Fix issues with rerendering blockless and tagless components. +- [#13605](https://github.com/emberjs/ember.js/pull/13605) [BUGFIX] Ensure `pauseTest` runs after other async helpers. +- [#13655](https://github.com/emberjs/ember.js/pull/13655) [BUGFIX] Make debugging `this._super` much easier (remove manual `.call` / `.apply` optimizations). +- [#13672](https://github.com/emberjs/ember.js/pull/13672) [BUGFIX] Fix issue with `this.render` and `this.disconnectOutlet` in routes. +- [#13716](https://github.com/emberjs/ember.js/pull/13716) [BUGFIX] Ensure that `Ember.Test.waiters` allows access to configured test waiters. +- [#13273](https://github.com/emberjs/ember.js/pull/13273) [BUGFIX] Fix a number of query param related issues reported. + ### 2.7.0-beta.1 (June 8, 2016) - [#13424](https://github.com/emberjs/ember.js/pull/13424) [DEPRECATE] Deprecate Ember.Binding. See [the deprecation guide](http://emberjs.com/deprecations/v2.x/#toc_ember-binding) for more details.
false
Other
emberjs
ember.js
b03759847fe171528e83a8d5aaf89b79aeda65e4.json
Add 2.6.1 changelog info. [ci skip] (cherry picked from commit 8b33eb2b827f64f2ce9cd04fd6fac25917aa8aa7)
CHANGELOG.md
@@ -5,6 +5,12 @@ - [#13424](https://github.com/emberjs/ember.js/pull/13424) [DEPRECATE] Deprecate Ember.Binding. See [the deprecation guide](http://emberjs.com/deprecations/v2.x/#toc_ember-binding) for more details. - [#13599](https://github.com/emberjs/ember.js/pull/13599) [FEATURE] Enable `ember-runtime-computed-uniq-by` feature. +### 2.6.1 (June 27, 2016) + +- [#13634](https://github.com/emberjs/ember.js/pull/13634) [BUGFIX] Fix issues with rerendering blockless and tagless components. +- [#13655](https://github.com/emberjs/ember.js/pull/13655) [BUGFIX] Make debugging `this._super` much easier (remove manual `.call` / `.apply` optimizations). +- [#13672](https://github.com/emberjs/ember.js/pull/13672) [BUGFIX] Fix issue with `this.render` and `this.disconnectOutlet` in routes. + ### 2.6.0 (June 8, 2016) - [#13520](https://github.com/emberjs/ember.js/pull/13520) [BUGFIX] Fixes issues with `baseURL` and `rootURL` in `Ember.HistoryLocation` and ensures that `Ember.NoneLocation` properly handles `rootURL`.
false
Other
emberjs
ember.js
f693865338abe24194f586a2bcb929821d172bd9.json
Add renetrant test for query params changes
packages/ember-routing/lib/system/router.js
@@ -717,11 +717,6 @@ const EmberRouter = EmberObject.extend(Evented, { assert(`The route ${targetRouteName} was not found`, targetRouteName && this.router.hasRoute(targetRouteName)); let queryParams = {}; - // merge in any queryParams from the active transition which could include - // queryparams from the url on initial load. - if (this.router.activeTransition) { - assign(queryParams, this.router.activeTransition.queryParams); - } this._processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams); @@ -738,7 +733,7 @@ const EmberRouter = EmberObject.extend(Evented, { _processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams) { // merge in any queryParams from the active transition which could include - // queryparams from the url on initial load. + // queryParams from the url on initial load. if (!this.router.activeTransition) { return; } var unchangedQPs = {}; @@ -749,9 +744,9 @@ const EmberRouter = EmberObject.extend(Evented, { } } - // We need to fully scope query params so that we can create one object - // that represetns both pased in query params and ones that arent' changed - // from the actice transition + // We need to fully scope queryParams so that we can create one object + // that represents both pased in queryParams and ones that aren't changed + // from the active transition. this._fullyScopeQueryParams(targetRouteName, models, _queryParams); this._fullyScopeQueryParams(targetRouteName, models, unchangedQPs); assign(queryParams, unchangedQPs);
true
Other
emberjs
ember.js
f693865338abe24194f586a2bcb929821d172bd9.json
Add renetrant test for query params changes
packages/ember/tests/routing/query_params_test.js
@@ -1,4 +1,5 @@ import Controller from 'ember-runtime/controllers/controller'; +import RSVP from 'ember-runtime/ext/rsvp'; import Route from 'ember-routing/system/route'; import run from 'ember-metal/run_loop'; import get from 'ember-metal/property_get'; @@ -2491,11 +2492,13 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); QUnit.test('queryParams are updated when a controller property is set and the route is refreshed. Issue #13263 ', function() { - Ember.TEMPLATES.application = compile( - '<button id="test-button" {{action \'increment\'}}>Increment</button>' + - '<span id="test-value">{{foo}}</span>' + - '{{outlet}}' - ); + setTemplates({ + application: compile( + '<button id="test-button" {{action \'increment\'}}>Increment</button>' + + '<span id="test-value">{{foo}}</span>' + + '{{outlet}}' + ) + }); App.ApplicationController = Controller.extend({ queryParams: ['foo'], foo: 1, @@ -3221,6 +3224,133 @@ if (isEnabled('ember-routing-route-configured-query-params')) { let controller = container.lookup('controller:example'); equal(get(controller, 'foo'), undefined); }); + + QUnit.test('when refreshModel is true and loading action returns false, model hook will rerun when QPs change even if previous did not finish', function() { + expect(6); + + var appModelCount = 0; + var promiseResolve; + + App.ApplicationRoute = Route.extend({ + queryParams: { + 'appomg': { + defaultValue: 'applol' + } + }, + model(params) { + appModelCount++; + } + }); + + App.IndexController = Controller.extend({ + queryParams: ['omg'] + // uncommon to not support default value, but should assume undefined. + }); + + var indexModelCount = 0; + App.IndexRoute = Route.extend({ + queryParams: { + omg: { + refreshModel: true + } + }, + actions: { + loading: function() { + return false; + } + }, + model(params) { + indexModelCount++; + if (indexModelCount === 2) { + deepEqual(params, { omg: 'lex' }); + return new RSVP.Promise(function(resolve) { + promiseResolve = resolve; + return; + }); + } else if (indexModelCount === 3) { + deepEqual(params, { omg: 'hello' }, 'Model hook reruns even if the previous one didnt finish'); + } + } + }); + + bootApplication(); + + equal(indexModelCount, 1); + + var indexController = container.lookup('controller:index'); + setAndFlush(indexController, 'omg', 'lex'); + equal(indexModelCount, 2); + + setAndFlush(indexController, 'omg', 'hello'); + equal(indexModelCount, 3); + run(function() { + promiseResolve(); + }); + equal(get(indexController, 'omg'), 'hello', 'At the end last value prevails'); + }); + + QUnit.test('when refreshModel is true and loading action does not return false, model hook will not rerun when QPs change even if previous did not finish', function() { + expect(7); + + var appModelCount = 0; + var promiseResolve; + + App.ApplicationRoute = Route.extend({ + queryParams: { + 'appomg': { + defaultValue: 'applol' + } + }, + model(params) { + appModelCount++; + } + }); + + App.IndexController = Controller.extend({ + queryParams: ['omg'] + // uncommon to not support default value, but should assume undefined. + }); + + var indexModelCount = 0; + App.IndexRoute = Route.extend({ + queryParams: { + omg: { + refreshModel: true + } + }, + model(params) { + indexModelCount++; + + if (indexModelCount === 2) { + deepEqual(params, { omg: 'lex' }); + return new RSVP.Promise(function(resolve) { + promiseResolve = resolve; + return; + }); + } else if (indexModelCount === 3) { + ok(false, 'shouldnt get here'); + } + } + }); + + bootApplication(); + + equal(appModelCount, 1); + equal(indexModelCount, 1); + + var indexController = container.lookup('controller:index'); + setAndFlush(indexController, 'omg', 'lex'); + + equal(appModelCount, 1); + equal(indexModelCount, 2); + + setAndFlush(indexController, 'omg', 'hello'); + equal(get(indexController, 'omg'), 'hello', ' value was set'); + equal(indexModelCount, 2); + run(function() { + promiseResolve(); + }); + }); } QUnit.test('warn user that routes query params configuration must be an Object, not an Array', function() {
true
Other
emberjs
ember.js
c9f42d7d43e6d63a522219199dbcc294416c6f1f.json
Fix JSHint issue.
packages/ember-htmlbars/lib/node-managers/view-node-manager.js
@@ -2,7 +2,6 @@ import assign from 'ember-metal/assign'; import { assert, warn } from 'ember-metal/debug'; import buildComponentTemplate from 'ember-htmlbars/system/build-component-template'; import { get } from 'ember-metal/property_get'; -import { set } from 'ember-metal/property_set'; import setProperties from 'ember-metal/set_properties'; import View from 'ember-views/views/view'; import { MUTABLE_CELL } from 'ember-views/compat/attrs-proxy';
false
Other
emberjs
ember.js
a85d6a19fc82ea86f137483a773aa0f1a0e15366.json
Remove legacy addon `viewName` support.
packages/ember-htmlbars/lib/node-managers/component-node-manager.js
@@ -87,7 +87,6 @@ function configureCreateOptions(attrs, createOptions) { // they are still streams. if (attrs.id) { createOptions.elementId = getValue(attrs.id); } if (attrs._defaultTagName) { createOptions._defaultTagName = getValue(attrs._defaultTagName); } - if (attrs.viewName) { createOptions.viewName = getValue(attrs.viewName); } } ComponentNodeManager.prototype.render = function ComponentNodeManager_render(_env, visitor) {
true
Other
emberjs
ember.js
a85d6a19fc82ea86f137483a773aa0f1a0e15366.json
Remove legacy addon `viewName` support.
packages/ember-htmlbars/lib/node-managers/view-node-manager.js
@@ -43,7 +43,6 @@ ViewNodeManager.create = function ViewNodeManager_create(renderNode, env, attrs, if (attrs && attrs.id) { options.elementId = getValue(attrs.id); } if (attrs && attrs.tagName) { options.tagName = getValue(attrs.tagName); } if (attrs && attrs._defaultTagName) { options._defaultTagName = getValue(attrs._defaultTagName); } - if (attrs && attrs.viewName) { options.viewName = getValue(attrs.viewName); } if (found.component.create && contentScope) { let _self = contentScope.getSelf(); @@ -211,10 +210,6 @@ export function createOrUpdateComponent(component, options, createOptions, rende if (options.parentView) { options.parentView.appendChild(component); - - if (options.viewName) { - set(options.parentView, options.viewName, component); - } } component._renderNode = renderNode;
true
Other
emberjs
ember.js
a85d6a19fc82ea86f137483a773aa0f1a0e15366.json
Remove legacy addon `viewName` support.
packages/ember-views/lib/mixins/view_support.js
@@ -585,17 +585,8 @@ export default Mixin.create({ @private */ destroy() { - // get parentView before calling super because it'll be destroyed - let parentView = this.parentView; - let viewName = this.viewName; - if (!this._super(...arguments)) { return; } - // remove from non-virtual parent view if viewName was specified - if (viewName && parentView) { - parentView.set(viewName, null); - } - // Destroy HTMLbars template if (this.lastResult) { this.lastResult.destroy();
true
Other
emberjs
ember.js
f69e66cf67e43a62b33e651edf4b39d70443c6e8.json
Remove ported tests. These tests were ported to the newer INUR style test setup, and can be removed.
packages/ember-htmlbars/lib/component.js
@@ -6,7 +6,6 @@ import TargetActionSupport from 'ember-runtime/mixins/target_action_support'; import ActionSupport from 'ember-views/mixins/action_support'; import View from 'ember-views/views/view'; -import { set } from 'ember-metal/property_set'; import { computed } from 'ember-metal/computed'; import { getOwner } from 'container/owner';
true
Other
emberjs
ember.js
f69e66cf67e43a62b33e651edf4b39d70443c6e8.json
Remove ported tests. These tests were ported to the newer INUR style test setup, and can be removed.
packages/ember-views/tests/views/component_test.js
@@ -1,19 +1,13 @@ -import { set } from 'ember-metal/property_set'; import run from 'ember-metal/run_loop'; -import EmberObject from 'ember-runtime/system/object'; import Service from 'ember-runtime/system/service'; import inject from 'ember-runtime/inject'; -import EmberView from 'ember-views/views/view'; import Component from 'ember-htmlbars/component'; -import { MUTABLE_CELL } from 'ember-views/compat/attrs-proxy'; import buildOwner from 'container/tests/test-helpers/build-owner'; import computed from 'ember-metal/computed'; -const a_slice = Array.prototype.slice; - -let component, controller, actionCounts, sendCount, actionArguments; +let component, controller; QUnit.module('Ember.Component', { setup() { @@ -83,133 +77,6 @@ QUnit.test('should warn if a non-array is used for classNameBindings', function( }, /Only arrays are allowed/i); }); -QUnit.module('Ember.Component - Actions', { - setup() { - actionCounts = {}; - sendCount = 0; - actionArguments = null; - - controller = EmberObject.create({ - send(actionName) { - sendCount++; - actionCounts[actionName] = actionCounts[actionName] || 0; - actionCounts[actionName]++; - actionArguments = a_slice.call(arguments, 1); - } - }); - - component = Component.create({ - parentView: EmberView.create({ - controller: controller - }) - }); - }, - - teardown() { - run(() => { - component.destroy(); - controller.destroy(); - }); - } -}); - -QUnit.test('Calling sendAction on a component without an action defined does nothing', function() { - component.sendAction(); - equal(sendCount, 0, 'addItem action was not invoked'); -}); - -QUnit.test('Calling sendAction on a component with an action defined calls send on the controller', function() { - set(component, 'action', 'addItem'); - - component.sendAction(); - - equal(sendCount, 1, 'send was called once'); - equal(actionCounts['addItem'], 1, 'addItem event was sent once'); -}); - -QUnit.test('Calling sendAction on a component with a function calls the function', function() { - expect(1); - set(component, 'action', function() { - ok(true, 'function is called'); - }); - - component.sendAction(); -}); - -QUnit.test('Calling sendAction on a component with a function calls the function with arguments', function() { - expect(1); - let argument = {}; - set(component, 'action', function(actualArgument) { - equal(actualArgument, argument, 'argument is passed'); - }); - - component.sendAction('action', argument); -}); - -QUnit.test('Calling sendAction on a component with a mut attr calls the function with arguments', function() { - let mut = { - value: 'didStartPlaying', - [MUTABLE_CELL]: true - }; - set(component, 'playing', null); - set(component, 'attrs', { playing: mut }); - - component.sendAction('playing'); - - equal(sendCount, 1, 'send was called once'); - equal(actionCounts['didStartPlaying'], 1, 'named action was sent'); -}); - -QUnit.test('Calling sendAction with a named action uses the component\'s property as the action name', function() { - set(component, 'playing', 'didStartPlaying'); - set(component, 'action', 'didDoSomeBusiness'); - - component.sendAction('playing'); - - equal(sendCount, 1, 'send was called once'); - equal(actionCounts['didStartPlaying'], 1, 'named action was sent'); - - component.sendAction('playing'); - - equal(sendCount, 2, 'send was called twice'); - equal(actionCounts['didStartPlaying'], 2, 'named action was sent'); - - component.sendAction(); - - equal(sendCount, 3, 'send was called three times'); - equal(actionCounts['didDoSomeBusiness'], 1, 'default action was sent'); -}); - -QUnit.test('Calling sendAction when the action name is not a string raises an exception', function() { - set(component, 'action', {}); - set(component, 'playing', {}); - - expectAssertion(() => component.sendAction()); - - expectAssertion(() => component.sendAction('playing')); -}); - -QUnit.test('Calling sendAction on a component with a context', function() { - set(component, 'playing', 'didStartPlaying'); - - let testContext = { song: 'She Broke My Ember' }; - - component.sendAction('playing', testContext); - - deepEqual(actionArguments, [testContext], 'context was sent with the action'); -}); - -QUnit.test('Calling sendAction on a component with multiple parameters', function() { - set(component, 'playing', 'didStartPlaying'); - - let firstContext = { song: 'She Broke My Ember' }; - let secondContext = { song: 'My Achey Breaky Ember' }; - - component.sendAction('playing', firstContext, secondContext); - - deepEqual(actionArguments, [firstContext, secondContext], 'arguments were sent to the action'); -}); - QUnit.module('Ember.Component - injected properties'); QUnit.test('services can be injected into components', function() {
true
Other
emberjs
ember.js
13afe72bd37cdf5db007bda269eca0d18e7f1ac7.json
Remove reference to `.controller` on components.
packages/ember-glimmer/lib/renderer.js
@@ -1,16 +1,17 @@ import { RootReference } from './utils/references'; import run from 'ember-metal/run_loop'; import { setHasViews } from 'ember-metal/tags'; -import { CURRENT_TAG } from 'glimmer-reference'; +import { CURRENT_TAG, UNDEFINED_REFERENCE } from 'glimmer-reference'; const { backburner } = run; class DynamicScope { - constructor({ view, controller, outletState, isTopLevel }) { + constructor({ view, controller, outletState, isTopLevel, targetObject }) { this.view = view; this.controller = controller; this.outletState = outletState; this.isTopLevel = isTopLevel; + this.targetObject = targetObject; } child() { @@ -130,9 +131,11 @@ class Renderer { let env = this._env; let self = new RootReference(view); + let controller = view.outletState.render.controller; let dynamicScope = new DynamicScope({ view, - controller: view.outletState.render.controller, + controller, + targetObject: controller, outletState: view.toReference(), isTopLevel: true }); @@ -149,7 +152,13 @@ class Renderer { appendTo(view, target) { let env = this._env; let self = new RootReference(view); - let dynamicScope = new DynamicScope({ view, controller: view.controller }); + let dynamicScope = new DynamicScope({ + view, + controller: undefined, + targetObject: undefined, + outletState: UNDEFINED_REFERENCE, + isTopLevel: true + }); env.begin(); let result = view.template.asEntryPoint().render(self, env, { appendTo: target, dynamicScope });
true
Other
emberjs
ember.js
13afe72bd37cdf5db007bda269eca0d18e7f1ac7.json
Remove reference to `.controller` on components.
packages/ember-glimmer/lib/syntax/curly-component.js
@@ -74,13 +74,16 @@ class CurlyComponentManager { props.renderer = parentView.renderer; props[HAS_BLOCK] = hasBlock; - // parentView.controller represents any parent components - // dynamicScope.controller represents the outlet controller - props._targetObject = parentView.controller || dynamicScope.controller; + + // dynamicScope here is inherited from the parent dynamicScope, + // but is set shortly below to the new target + props._targetObject = dynamicScope.targetObject; let component = klass.create(props); dynamicScope.view = component; + dynamicScope.targetObject = component; + parentView.appendChild(component); component.trigger('didInitAttrs', { attrs });
true
Other
emberjs
ember.js
13afe72bd37cdf5db007bda269eca0d18e7f1ac7.json
Remove reference to `.controller` on components.
packages/ember-glimmer/lib/syntax/outlet.js
@@ -130,7 +130,7 @@ class OutletComponentManager extends AbstractOutletComponentManager { create(definition, args, dynamicScope) { let outletStateReference = dynamicScope.outletState = dynamicScope.outletState.get(definition.outletName); let outletState = outletStateReference.value(); - dynamicScope.controller = outletState.render.controller; + dynamicScope.targetObject = dynamicScope.controller = outletState.render.controller; return outletState; } }
true
Other
emberjs
ember.js
7d1a8d5800db55664e16c5955ec14f9930181406.json
Remove usage of `targetObject` computed property. This PR removes the `targetObject` CP in favor of simply looking up the correct `targetObject` when needed. This simplifies the code path for `sendAction` and removes some overloading of the term "controller" (before this change it could mean an actual outlet's controller or the parentView.controller which may be a component and not a "real" controller).
packages/ember-glimmer/lib/syntax/curly-component.js
@@ -74,19 +74,15 @@ class CurlyComponentManager { props.renderer = parentView.renderer; props[HAS_BLOCK] = hasBlock; + // parentView.controller represents any parent components + // dynamicScope.controller represents the outlet controller + props._targetObject = parentView.controller || dynamicScope.controller; let component = klass.create(props); dynamicScope.view = component; parentView.appendChild(component); - if (parentView.controller) { - dynamicScope.controller = parentView.controller; - } - - component._controller = dynamicScope.controller; - - component.trigger('didInitAttrs', { attrs }); component.trigger('didReceiveAttrs', { newAttrs: attrs }); component.trigger('willInsertElement');
true
Other
emberjs
ember.js
7d1a8d5800db55664e16c5955ec14f9930181406.json
Remove usage of `targetObject` computed property. This PR removes the `targetObject` CP in favor of simply looking up the correct `targetObject` when needed. This simplifies the code path for `sendAction` and removes some overloading of the term "controller" (before this change it could mean an actual outlet's controller or the parentView.controller which may be a component and not a "real" controller).
packages/ember-runtime/lib/mixins/target_action_support.js
@@ -29,25 +29,6 @@ export default Mixin.create({ action: null, actionContext: null, - targetObject: computed('target', function() { - if (this._targetObject) { - return this._targetObject; - } - - let target = get(this, 'target'); - - if (typeof target === 'string') { - let value = get(this, target); - if (value === undefined) { - value = get(context.lookup, target); - } - - return value; - } else { - return target; - } - }), - actionContextObject: computed('actionContext', function() { let actionContext = get(this, 'actionContext'); @@ -115,7 +96,12 @@ export default Mixin.create({ */ triggerAction(opts = {}) { let action = opts.action || get(this, 'action'); - let target = opts.target || get(this, 'targetObject'); + let target = opts.target; + + if (!target) { + target = getTarget(this); + } + let actionContext = opts.actionContext; function args(options, actionName) { @@ -149,3 +135,36 @@ export default Mixin.create({ } } }); + +function getTarget(instance) { + // TODO: Deprecate specifying `targetObject` + let target = get(instance, 'targetObject'); + + // if a `targetObject` CP was provided, use it + if (target) { return target; } + + // if _targetObject use it + if (instance._targetObject) { return instance._targetObject; } + + target = get(instance, 'target'); + if (target) { + if (typeof target === 'string') { + let value = get(instance, target); + if (value === undefined) { + value = get(context.lookup, target); + } + + return value; + } else { + return target; + } + } + + if (instance._controller) { return instance._controller; } + + // fallback to `parentView.controller` + let parentViewController = get(instance, 'parentView.controller'); + if (parentViewController) { return parentViewController; } + + return null; +}
true
Other
emberjs
ember.js
7d1a8d5800db55664e16c5955ec14f9930181406.json
Remove usage of `targetObject` computed property. This PR removes the `targetObject` CP in favor of simply looking up the correct `targetObject` when needed. This simplifies the code path for `sendAction` and removes some overloading of the term "controller" (before this change it could mean an actual outlet's controller or the parentView.controller which may be a component and not a "real" controller).
packages/ember-views/lib/mixins/action_support.js
@@ -1,5 +1,4 @@ import { Mixin } from 'ember-metal/mixin'; -import { computed } from 'ember-metal/computed'; import { get } from 'ember-metal/property_get'; import isNone from 'ember-metal/is_none'; import { assert } from 'ember-metal/debug'; @@ -124,22 +123,6 @@ export default Mixin.create({ } }, - /** - If the component is currently inserted into the DOM of a parent view, this - property will point to the controller of the parent view. - - @property targetObject - @type Ember.Controller - @default null - @private - */ - targetObject: computed('controller', function(key) { - if (this._targetObject) { return this._targetObject; } - if (this._controller) { return this._controller; } - let parentView = get(this, 'parentView'); - return parentView ? get(parentView, 'controller') : null; - }), - send(actionName, ...args) { let target; let action = this.actions && this.actions[actionName];
true
Other
emberjs
ember.js
81a375b24351dc90db40b55f4fee4ce1b75c0ec2.json
Fix "super() use outside of constructor" issues
packages/ember-glimmer/tests/integration/components/closure-components-test.js
@@ -635,7 +635,7 @@ moduleFor('@htmlbars Components test: closure components', class extends Renderi class ClosureComponentMutableParamsTest extends RenderingTest { render(templateStr, context = {}) { - super(`${templateStr}<span class="value">{{model.val2}}</span>`, assign(context, { model: { val2: 8 } })); + super.render(`${templateStr}<span class="value">{{model.val2}}</span>`, assign(context, { model: { val2: 8 } })); } }
true
Other
emberjs
ember.js
81a375b24351dc90db40b55f4fee4ce1b75c0ec2.json
Fix "super() use outside of constructor" issues
packages/ember-glimmer/tests/integration/content-test.js
@@ -952,7 +952,7 @@ if (!EmberDev.runningProdBuild) { } teardown() { - super(...arguments); + super.teardown(...arguments); setDebugFunction('warn', originalWarn); }
true
Other
emberjs
ember.js
81a375b24351dc90db40b55f4fee4ce1b75c0ec2.json
Fix "super() use outside of constructor" issues
packages/ember-glimmer/tests/integration/helpers/loc-test.js
@@ -14,7 +14,7 @@ moduleFor('Helpers test: {{loc}}', class extends RenderingTest { } teardown() { - super(); + super.teardown(); Ember.STRINGS = this.oldString; }
true
Other
emberjs
ember.js
81a375b24351dc90db40b55f4fee4ce1b75c0ec2.json
Fix "super() use outside of constructor" issues
packages/ember-glimmer/tests/integration/helpers/log-test.js
@@ -15,7 +15,7 @@ moduleFor('Helpers test: {{log}}', class extends RenderingTest { } teardown() { - super(); + super.teardown(); Logger.log = this.originalLog; }
true
Other
emberjs
ember.js
81a375b24351dc90db40b55f4fee4ce1b75c0ec2.json
Fix "super() use outside of constructor" issues
packages/ember-testing/lib/test/promise.js
@@ -14,7 +14,7 @@ export default class TestPromise extends RSVP.Promise { } then(onFulfillment, ...args) { - return super(result => isolate(onFulfillment, result), ...args); + return super.then(result => isolate(onFulfillment, result), ...args); } }
true
Other
emberjs
ember.js
eabf61d42fcfaa6dde82f7f16304f08a0d5a61d0.json
Implement automatic mutable bindings ("auto-mut") Because everything in the new (curly) Component implementation is fully two-way-bound by default, this does not actually require the `{{mut}}` helper.
packages/ember-glimmer-template-compiler/lib/plugins/transform-attrs-into-props.js
@@ -0,0 +1,47 @@ +/** + @module ember + @submodule ember-glimmer +*/ + +/** + A Glimmer2 AST transformation that replaces all instances of + + ```handlebars + {{attrs.foo.bar}} + ``` + + to + + ```handlebars + {{foo.bar}} + ``` + + as well as `{{#if attrs.foo}}`, `{{deeply (nested attrs.foobar.baz)}}` etc + + @private + @class TransformAttrsToProps +*/ + +export default function TransformAttrsToProps() { + // set later within Glimmer2 to the syntax package + this.syntax = null; +} + +/** + @private + @method transform + @param {AST} ast The AST to be transformed. +*/ +TransformAttrsToProps.prototype.transform = function TransformAttrsToProps_transform(ast) { + let { traverse, builders: b } = this.syntax; + + traverse(ast, { + PathExpression(node) { + if (node.parts[0] === 'attrs') { + return b.path(node.original.substr(6)); + } + } + }); + + return ast; +};
true
Other
emberjs
ember.js
eabf61d42fcfaa6dde82f7f16304f08a0d5a61d0.json
Implement automatic mutable bindings ("auto-mut") Because everything in the new (curly) Component implementation is fully two-way-bound by default, this does not actually require the `{{mut}}` helper.
packages/ember-glimmer-template-compiler/lib/system/compile-options.js
@@ -1,15 +1,17 @@ import defaultPlugins from 'ember-template-compiler/plugins'; -import TransformHasBlockSyntax from '../plugins/transform-has-block-syntax'; import TransformActionSyntax from '../plugins/transform-action-syntax'; +import TransformAttrsIntoProps from '../plugins/transform-attrs-into-props'; import TransformEachInIntoEach from '../plugins/transform-each-in-into-each'; +import TransformHasBlockSyntax from '../plugins/transform-has-block-syntax'; import assign from 'ember-metal/assign'; export const PLUGINS = [ ...defaultPlugins, // the following are ember-glimmer specific - TransformHasBlockSyntax, TransformActionSyntax, - TransformEachInIntoEach + TransformAttrsIntoProps, + TransformEachInIntoEach, + TransformHasBlockSyntax ]; let USER_PLUGINS = [];
true
Other
emberjs
ember.js
eabf61d42fcfaa6dde82f7f16304f08a0d5a61d0.json
Implement automatic mutable bindings ("auto-mut") Because everything in the new (curly) Component implementation is fully two-way-bound by default, this does not actually require the `{{mut}}` helper.
packages/ember-glimmer/lib/utils/process-args.js
@@ -3,7 +3,6 @@ import symbol from 'ember-metal/symbol'; import { assert } from 'ember-metal/debug'; import EmptyObject from 'ember-metal/empty_object'; import { ARGS } from '../component'; -import { isMut } from '../helpers/mut'; import { UPDATE } from './references'; export default function processArgs(args, positionalParamsDefinition) { @@ -53,7 +52,7 @@ class SimpleArgs { let ref = namedArgs.get(name); let value = attrs[name]; - if (isMut(ref)) { + if (ref[UPDATE]) { attrs[name] = new MutableCell(ref, value); }
true
Other
emberjs
ember.js
eabf61d42fcfaa6dde82f7f16304f08a0d5a61d0.json
Implement automatic mutable bindings ("auto-mut") Because everything in the new (curly) Component implementation is fully two-way-bound by default, this does not actually require the `{{mut}}` helper.
packages/ember-glimmer/tests/integration/components/dynamic-components-test.js
@@ -508,12 +508,12 @@ moduleFor('Components test: dynamic components', class extends RenderingTest { ['@test component helper properly invalidates hash params inside an {{each}} invocation #11044'](assert) { this.registerComponent('foo-bar', { - template: '[{{internalName}} - {{attrs.name}}]', + template: '[{{internalName}} - {{name}}]', ComponentClass: Component.extend({ willRender() { // store internally available name to ensure that the name available in `this.attrs.name` // matches the template lookup name - set(this, 'internalName', this.attrs.name); + set(this, 'internalName', this.get('name')); } }) });
true
Other
emberjs
ember.js
eabf61d42fcfaa6dde82f7f16304f08a0d5a61d0.json
Implement automatic mutable bindings ("auto-mut") Because everything in the new (curly) Component implementation is fully two-way-bound by default, this does not actually require the `{{mut}}` helper.
packages/ember-glimmer/tests/integration/helpers/mut-test.js
@@ -340,7 +340,40 @@ moduleFor('Helpers test: {{mut}}', class extends RenderingTest { this.assertText('12'); } - ['@htmlbars automatic mutable bindings tolerate undefined non-stream inputs and attempts to set them']() { + ['@test automatic mutable bindings exposes a mut cell in attrs']() { + let inner; + + this.registerComponent('x-inner', { + ComponentClass: Component.extend({ + didInsertElement() { + inner = this; + } + }), + template: '{{foo}}' + }); + + this.registerComponent('x-outer', { + template: '{{x-inner foo=bar}}' + }); + + this.render('{{x-outer bar=baz}}', { baz: 'foo' }); + + this.assertText('foo'); + + this.assertStableRerender(); + + this.runTask(() => inner.attrs.foo.update('bar')); + + this.assert.equal(inner.attrs.foo.value, 'bar'); + this.assert.equal(get(inner, 'foo'), 'bar'); + this.assertText('bar'); + + this.runTask(() => inner.attrs.foo.update('foo')); + + this.assertText('foo'); + } + + ['@test automatic mutable bindings tolerate undefined non-stream inputs and attempts to set them']() { let inner; this.registerComponent('x-inner', { @@ -373,6 +406,8 @@ moduleFor('Helpers test: {{mut}}', class extends RenderingTest { this.assertText(''); } + // TODO: This is not really consistent with how the rest of the system works. Investigate if we need to + // support this, if not then this test can be deleted. ['@htmlbars automatic mutable bindings tolerate constant non-stream inputs and attempts to set them']() { let inner;
true
Other
emberjs
ember.js
f09e338a895314ff80c2f819ac33dc41d5256f3e.json
Update jQuery version for package manager
bower.json
@@ -5,7 +5,7 @@ "url": "https://github.com/emberjs/ember.js.git" }, "dependencies": { - "jquery": ">=1.11.1 <3.0.0", + "jquery": ">=1.11.1 <4.0.0", "qunit": "^1.20.0", "qunit-phantom-runner": "jonkemp/qunit-phantomjs-runner#1.2.0" },
true
Other
emberjs
ember.js
f09e338a895314ff80c2f819ac33dc41d5256f3e.json
Update jQuery version for package manager
config/package_manager_files/bower.json
@@ -12,6 +12,6 @@ "url": "https://github.com/emberjs/ember.js.git" }, "dependencies": { - "jquery": ">= 1.7.0 < 3.0.0" + "jquery": ">= 1.7.0 < 4.0.0" } }
true
Other
emberjs
ember.js
f09e338a895314ff80c2f819ac33dc41d5256f3e.json
Update jQuery version for package manager
config/package_manager_files/component.json
@@ -9,6 +9,6 @@ "ember.debug.js" ], "dependencies": { - "components/jquery": ">= 1.7.0 < 3.0.0" + "components/jquery": ">= 1.7.0 < 4.0.0" } }
true
Other
emberjs
ember.js
f09e338a895314ff80c2f819ac33dc41d5256f3e.json
Update jQuery version for package manager
config/package_manager_files/composer.json
@@ -5,7 +5,7 @@ "license": "MIT", "homepage": "https://github.com/emberjs/ember.js", "require": { - "components/jquery": ">=1.7.0, < 3.0.0" + "components/jquery": ">=1.7.0, < 4.0.0" }, "extra": { "component": {
true
Other
emberjs
ember.js
f09e338a895314ff80c2f819ac33dc41d5256f3e.json
Update jQuery version for package manager
config/package_manager_files/package.json
@@ -9,7 +9,7 @@ ], "main": "./ember.debug.js", "dependencies": { - "jquery": ">=1.7.0 <3.0.0" + "jquery": ">=1.7.0 <4.0.0" }, "jspm": { "main": "ember.debug",
true
Other
emberjs
ember.js
5f5407c589fb5a6b00109e55900b681c3f251e96.json
Add test for `.removeAt` Add test for `.removeAt` using prototype extensions. Update comments.
packages/ember-runtime/lib/mixins/mutable_array.js
@@ -146,9 +146,9 @@ export default Mixin.create(EmberArray, MutableEnumerable, { ```javascript let colors = ['red', 'green', 'blue', 'yellow', 'orange']; - removeAt(colors, 0); // ['green', 'blue', 'yellow', 'orange'] - removeAt(colors, 2, 2); // ['green', 'blue'] - removeAt(colors, 4, 2); // Error: Index out of range + colors.removeAt(0); // ['green', 'blue', 'yellow', 'orange'] + colors.removeAt(2, 2); // ['green', 'blue'] + colors.removeAt(4, 2); // Error: Index out of range ``` @method removeAt
true
Other
emberjs
ember.js
5f5407c589fb5a6b00109e55900b681c3f251e96.json
Add test for `.removeAt` Add test for `.removeAt` using prototype extensions. Update comments.
packages/ember-runtime/lib/system/array_proxy.js
@@ -35,38 +35,6 @@ const EMPTY = []; function K() { return this; } -export function removeAt(array, start, len) { - if ('number' === typeof start) { - let content = get(array, 'content'); - let arrangedContent = get(array, 'arrangedContent'); - let indices = []; - - if ((start < 0) || (start >= get(array, 'length'))) { - throw new EmberError(OUT_OF_RANGE_EXCEPTION); - } - - if (len === undefined) { - len = 1; - } - - // Get a list of indices in original content to remove - for (let i = start; i < start + len; i++) { - // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent - indices.push(content.indexOf(objectAt(arrangedContent, i))); - } - - // Replace in reverse order since indices will change - indices.sort((a, b) => b - a); - - beginPropertyChanges(); - for (let i = 0; i < indices.length; i++) { - array._replace(indices[i], 1, EMPTY); - } - endPropertyChanges(); - } - - return array; -} /** An ArrayProxy wraps any other object that implements `Ember.Array` and/or @@ -335,7 +303,36 @@ export default EmberObject.extend(MutableArray, { }, removeAt(start, len) { - return removeAt(this, start, len); + if ('number' === typeof start) { + let content = get(this, 'content'); + let arrangedContent = get(this, 'arrangedContent'); + let indices = []; + + if ((start < 0) || (start >= get(this, 'length'))) { + throw new EmberError(OUT_OF_RANGE_EXCEPTION); + } + + if (len === undefined) { + len = 1; + } + + // Get a list of indices in original content to remove + for (let i = start; i < start + len; i++) { + // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent + indices.push(content.indexOf(objectAt(arrangedContent, i))); + } + + // Replace in reverse order since indices will change + indices.sort((a, b) => b - a); + + beginPropertyChanges(); + for (let i = 0; i < indices.length; i++) { + this._replace(indices[i], 1, EMPTY); + } + endPropertyChanges(); + } + + return this; }, pushObject(obj) {
true
Other
emberjs
ember.js
5f5407c589fb5a6b00109e55900b681c3f251e96.json
Add test for `.removeAt` Add test for `.removeAt` using prototype extensions. Update comments.
packages/ember-runtime/tests/suites/mutable_array/removeAt.js
@@ -26,7 +26,6 @@ suite.test('removeAt([X], 0) => [] + notify', function() { equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); }); -<<<<<<< f34dbabccfaa97c5d8989ce3ce4ec196e2450bbf suite.test('removeAt([], 200) => OUT_OF_RANGE_EXCEPTION exception', function() { let obj = this.newObject([]); throws(() => removeAt(obj, 200), Error); @@ -116,4 +115,26 @@ suite.test('removeAt([A,B,C,D], 1,2) => [A,D] + notify', function() { equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); }); +suite.test('[A,B,C,D].removeAt(1,2) => [A,D] + notify', function() { + var obj, before, after, observer; + + before = this.newFixture(4); + after = [before[0], before[3]]; + obj = this.newObject(before); + observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.removeAt(1, 2), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); +}); + export default suite;
true
Other
emberjs
ember.js
5f5407c589fb5a6b00109e55900b681c3f251e96.json
Add test for `.removeAt` Add test for `.removeAt` using prototype extensions. Update comments.
packages/ember-runtime/tests/system/array_proxy/arranged_content_test.js
@@ -1,6 +1,6 @@ import run from 'ember-metal/run_loop'; import { computed } from 'ember-metal/computed'; -import ArrayProxy, { removeAt } from 'ember-runtime/system/array_proxy'; +import ArrayProxy from 'ember-runtime/system/array_proxy'; import { A as emberA } from 'ember-runtime/system/native_array'; import { objectAt } from 'ember-runtime/mixins/array'; @@ -101,7 +101,7 @@ QUnit.test('pushObjects - adds multiple to end of content even if it already exi }); QUnit.test('removeAt - removes from index in arrangedContent', function() { - run(() => removeAt(array, 1, 2)); + run(() => array.removeAt(1, 2)); deepEqual(array.get('content'), [1, 5]); });
true
Other
emberjs
ember.js
29a1fc2114b28b8fa25ba4dd88e807ead1f581d9.json
Remove artificial isEnabled tests.
packages/ember-metal/tests/features_test.js
@@ -1,46 +0,0 @@ -import { ENV } from 'ember-environment'; -import isEnabled, { FEATURES } from 'ember-metal/features'; -import assign from 'ember-metal/assign'; - -var origFeatures, origEnableOptional; - -QUnit.module('isEnabled', { - setup() { - origFeatures = assign({}, FEATURES); - origEnableOptional = ENV.ENABLE_OPTIONAL_FEATURES; - }, - - teardown() { - for (var feature in FEATURES) { - delete FEATURES[feature]; - } - assign(FEATURES, origFeatures); - - ENV.ENABLE_OPTIONAL_FEATURES = origEnableOptional; - } -}); - -QUnit.test('ENV.ENABLE_OPTIONAL_FEATURES', function() { - ENV.ENABLE_OPTIONAL_FEATURES = true; - FEATURES['fred'] = false; - FEATURES['barney'] = true; - FEATURES['wilma'] = null; - - equal(isEnabled('fred'), false, 'returns flag value if false'); - equal(isEnabled('barney'), true, 'returns flag value if true'); - equal(isEnabled('wilma'), true, 'returns true if flag is not true|false|undefined'); - equal(isEnabled('betty'), undefined, 'returns flag value if undefined'); -}); - -QUnit.test('isEnabled without ENV options', function() { - ENV.ENABLE_OPTIONAL_FEATURES = false; - - FEATURES['fred'] = false; - FEATURES['barney'] = true; - FEATURES['wilma'] = null; - - equal(isEnabled('fred'), false, 'returns flag value if false'); - equal(isEnabled('barney'), true, 'returns flag value if true'); - equal(isEnabled('wilma'), false, 'returns false if flag is not set'); - equal(isEnabled('betty'), undefined, 'returns flag value if undefined'); -});
false
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-htmlbars/lib/env.js
@@ -1,4 +1,4 @@ -import { environment, ENV } from 'ember-environment'; +import { environment } from 'ember-environment'; import { hooks } from 'htmlbars-runtime'; import assign from 'ember-metal/assign'; @@ -72,7 +72,6 @@ import debuggerKeyword from 'ember-htmlbars/keywords/debugger'; import withKeyword from 'ember-htmlbars/keywords/with'; import outlet from 'ember-htmlbars/keywords/outlet'; import unbound from 'ember-htmlbars/keywords/unbound'; -import view from 'ember-htmlbars/keywords/view'; import componentKeyword from 'ember-htmlbars/keywords/component'; import elementComponent from 'ember-htmlbars/keywords/element-component'; import partial from 'ember-htmlbars/keywords/partial'; @@ -104,11 +103,6 @@ registerKeyword('action', actionKeyword); registerKeyword('render', renderKeyword); registerKeyword('@element_action', elementActionKeyword); -if (ENV._ENABLE_LEGACY_VIEW_SUPPORT) { - registerKeyword('view', view); -} - - export default { hooks: emberHooks, helpers: helpers,
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-htmlbars/lib/keywords/view.js
@@ -1,289 +0,0 @@ -/** -@module ember -@submodule ember-templates -*/ - -import { readViewFactory } from '../streams/utils'; -import EmberView from 'ember-views/views/view'; -import ViewNodeManager from 'ember-htmlbars/node-managers/view-node-manager'; - -/** - `{{view}}` inserts a new instance of an `Ember.View` into a template passing its - options to the `Ember.View`'s `create` method and using the supplied block as - the view's own template. - - An empty `<body>` and the following template: - - ```handlebars - A span: - {{#view tagName="span"}} - hello. - {{/view}} - ``` - - Will result in HTML structure: - - ```html - <body> - <!-- Note: the handlebars template script - also results in a rendered Ember.View - which is the outer <div> here --> - - <div class="ember-view"> - A span: - <span id="ember1" class="ember-view"> - Hello. - </span> - </div> - </body> - ``` - - ### `parentView` setting - - The `parentView` property of the new `Ember.View` instance created through - `{{view}}` will be set to the `Ember.View` instance of the template where - `{{view}}` was called. - - ```javascript - aView = Ember.View.create({ - template: Ember.Handlebars.compile("{{#view}} my parent: {{parentView.elementId}} {{/view}}") - }); - - aView.appendTo('body'); - ``` - - Will result in HTML structure: - - ```html - <div id="ember1" class="ember-view"> - <div id="ember2" class="ember-view"> - my parent: ember1 - </div> - </div> - ``` - - ### Setting CSS id and class attributes - - The HTML `id` attribute can be set on the `{{view}}`'s resulting element with - the `id` option. This option will _not_ be passed to `Ember.View.create`. - - ```handlebars - {{#view tagName="span" id="a-custom-id"}} - hello. - {{/view}} - ``` - - Results in the following HTML structure: - - ```html - <div class="ember-view"> - <span id="a-custom-id" class="ember-view"> - hello. - </span> - </div> - ``` - - The HTML `class` attribute can be set on the `{{view}}`'s resulting element - with the `class` or `classNameBindings` options. The `class` option will - directly set the CSS `class` attribute and will not be passed to - `Ember.View.create`. `classNameBindings` will be passed to `create` and use - `Ember.View`'s class name binding functionality: - - ```handlebars - {{#view tagName="span" class="a-custom-class"}} - hello. - {{/view}} - ``` - - Results in the following HTML structure: - - ```html - <div class="ember-view"> - <span id="ember2" class="ember-view a-custom-class"> - hello. - </span> - </div> - ``` - - ### Supplying a different view class - - `{{view}}` can take an optional first argument before its supplied options to - specify a path to a custom view class. - - ```handlebars - {{#view "custom"}}{{! will look up App.CustomView }} - hello. - {{/view}} - ``` - - The first argument can also be a relative path accessible from the current - context. - - ```javascript - MyApp = Ember.Application.create({}); - MyApp.OuterView = Ember.View.extend({ - innerViewClass: Ember.View.extend({ - classNames: ['a-custom-view-class-as-property'] - }), - template: Ember.Handlebars.compile('{{#view view.innerViewClass}} hi {{/view}}') - }); - - MyApp.OuterView.create().appendTo('body'); - ``` - - Will result in the following HTML: - - ```html - <div id="ember1" class="ember-view"> - <div id="ember2" class="ember-view a-custom-view-class-as-property"> - hi - </div> - </div> - ``` - - ### Blockless use - - If you supply a custom `Ember.View` subclass that specifies its own template - or provide a `templateName` option to `{{view}}` it can be used without - supplying a block. Attempts to use both a `templateName` option and supply a - block will throw an error. - - ```javascript - var App = Ember.Application.create(); - App.WithTemplateDefinedView = Ember.View.extend({ - templateName: 'defined-template' - }); - ``` - - ```handlebars - {{! application.hbs }} - {{view 'with-template-defined'}} - ``` - - ```handlebars - {{! defined-template.hbs }} - Some content for the defined template view. - ``` - - ### `viewName` property - - You can supply a `viewName` option to `{{view}}`. The `Ember.View` instance - will be referenced as a property of its parent view by this name. - - ```javascript - aView = Ember.View.create({ - template: Ember.Handlebars.compile('{{#view viewName="aChildByName"}} hi {{/view}}') - }); - - aView.appendTo('body'); - aView.get('aChildByName') // the instance of Ember.View created by {{view}} helper - ``` - - @method view - @for Ember.Templates.helpers - @public - @deprecated -*/ - -export default { - setupState(state, env, scope, params, hash) { - var read = env.hooks.getValue; - var targetObject = read(scope.getSelf()); - var viewClassOrInstance = state.viewClassOrInstance; - if (!viewClassOrInstance) { - viewClassOrInstance = getView(read(params[0]), env.owner); - } - - // if parentView exists, use its controller (the default - // behavior), otherwise use `scope.self` as the controller - var controller = scope.hasLocal('view') ? null : read(scope.getSelf()); - - return { - manager: state.manager, - parentView: env.view, - controller, - targetObject, - viewClassOrInstance - }; - }, - - rerender(morph, env, scope, params, hash, template, inverse, visitor) { - // If the hash is empty, the component cannot have extracted a part - // of a mutable param and used it in its layout, because there are - // no params at all. - if (Object.keys(hash).length) { - return morph.getState().manager.rerender(env, hash, visitor, true); - } - }, - - render(node, env, scope, params, hash, template, inverse, visitor) { - if (hash.tag) { - hash = swapKey(hash, 'tag', 'tagName'); - } - - if (hash.classNameBindings) { - hash.classNameBindings = hash.classNameBindings.split(' '); - } - - var state = node.getState(); - var parentView = state.parentView; - - var options = { - component: state.viewClassOrInstance, - layout: null - }; - - options.createOptions = {}; - if (state.controller) { - // Use `_controller` to avoid stomping on a CP - // that exists in the target view/component - options.createOptions._controller = state.controller; - } - - if (state.targetObject) { - // Use `_targetObject` to avoid stomping on a CP - // that exists in the target view/component - options.createOptions._targetObject = state.targetObject; - } - - if (state.manager) { - state.manager.destroy(); - state.manager = null; - } - - var nodeManager = ViewNodeManager.create(node, env, hash, options, parentView, null, scope, template); - state.manager = nodeManager; - - nodeManager.render(env, hash, visitor); - } -}; - -function getView(viewPath, owner) { - var viewClassOrInstance; - - if (!viewPath) { - if (owner) { - viewClassOrInstance = owner._lookupFactory('view:toplevel'); - } else { - viewClassOrInstance = EmberView; - } - } else { - viewClassOrInstance = readViewFactory(viewPath, owner); - } - - return viewClassOrInstance; -} - -function swapKey(hash, original, update) { - var newHash = {}; - - for (var prop in hash) { - if (prop === original) { - newHash[update] = hash[prop]; - } else { - newHash[prop] = hash[prop]; - } - } - - return newHash; -}
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-testing/tests/helpers_test.js
@@ -4,8 +4,8 @@ import run from 'ember-metal/run_loop'; import EmberObject from 'ember-runtime/system/object'; import RSVP from 'ember-runtime/ext/rsvp'; import EmberView from 'ember-views/views/view'; -import Checkbox from 'ember-htmlbars/components/checkbox'; import jQuery from 'ember-views/system/jquery'; +import Component from 'ember-templates/component'; import Test from 'ember-testing/test'; import 'ember-testing/helpers'; // ensure that the helpers are loaded @@ -16,8 +16,6 @@ import EmberRoute from 'ember-routing/system/route'; import EmberApplication from 'ember-application/system/application'; import { compile } from 'ember-template-compiler/tests/utils/helpers'; -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; import { pendingRequests, @@ -35,7 +33,6 @@ import { var App; var originalAdapter = getAdapter(); -var originalViewKeyword; function cleanup() { // Teardown setupForTesting @@ -269,12 +266,10 @@ QUnit.test('Ember.Application#removeTestHelpers resets the helperContainer\'s or QUnit.module('ember-testing: Helper methods', { setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); setupApp(); }, teardown() { cleanup(); - resetKeyword('view', originalViewKeyword); } }); @@ -362,20 +357,22 @@ test('`click` triggers appropriate events in order', function() { this.$().on('mousedown focusin mouseup click', function(e) { events.push(e.type); }); - }, - - Checkbox: Checkbox.extend({ - click() { - events.push('click:' + this.get('checked')); - }, + } + }); - change() { - events.push('change:' + this.get('checked')); - } - }) + App.XCheckboxComponent = Component.extend({ + tagName: 'input', + attributeBindings: ['type'], + type: 'checkbox', + click() { + events.push('click:' + this.get('checked')); + }, + change() { + events.push('change:' + this.get('checked')); + } }); - setTemplate('index', compile('{{input type="text"}} {{view view.Checkbox}} {{textarea}} <div contenteditable="true"> </div>')); + setTemplate('index', compile('{{input type="text"}} {{x-checkbox type="checkbox"}} {{textarea}} <div contenteditable="true"> </div>')); run(App, App.advanceReadiness);
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-testing/tests/integration_test.js
@@ -70,7 +70,7 @@ QUnit.module('ember-testing Integration', { } }); -import { test } from 'ember-glimmer/tests/utils/skip-if-glimmer'; +import { test } from 'internal-test-helpers/tests/skip-if-glimmer'; test('template is bound to empty array of people', function() { App.Person.find = function() {
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/compat/view_render_hook_test.js
@@ -1,19 +1,13 @@ import { runDestroy } from 'ember-runtime/tests/utils'; import View from 'ember-views/views/view'; -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; -var view, parentView, originalViewKeyword; +var view, parentView; QUnit.module('ember-views: View#render hook', { - setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); - }, teardown() { runDestroy(view); runDestroy(parentView); - resetKeyword('view', originalViewKeyword); } });
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/system/event_dispatcher_test.js
@@ -12,21 +12,15 @@ import Component from 'ember-htmlbars/component'; import buildOwner from 'container/tests/test-helpers/build-owner'; import { OWNER } from 'container/owner'; import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; - -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; - import { subscribe, reset } from 'ember-metal/instrumentation'; -var owner, view, originalViewKeyword; +var owner, view; var dispatcher; import isEnabled from 'ember-metal/features'; QUnit.module('EventDispatcher', { setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); - owner = buildOwner(); owner.registerOptionsForType('component', { singleton: false }); owner.registerOptionsForType('view', { singleton: false }); @@ -43,7 +37,6 @@ QUnit.module('EventDispatcher', { runDestroy(view); runDestroy(owner); reset(); - resetKeyword('view', originalViewKeyword); } });
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/views/view/append_to_test.js
@@ -10,10 +10,7 @@ import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; import buildOwner from 'container/tests/test-helpers/build-owner'; import { OWNER } from 'container/owner'; -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; - -var owner, View, view, otherView, willDestroyCalled, originalViewKeyword; +var owner, View, view, otherView, willDestroyCalled; function commonSetup() { owner = buildOwner(); @@ -25,14 +22,12 @@ function commonSetup() { QUnit.module('EmberView - append() and appendTo()', { setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); View = EmberView.extend({}); }, teardown() { runDestroy(view); runDestroy(otherView); - resetKeyword('view', originalViewKeyword); } }); @@ -98,29 +93,6 @@ QUnit.test('raises an assert when a target does not exist in the DOM', function( }); }); -QUnit.test('trigger rerender of parent and SimpleBoundView', function () { - var view = EmberView.create({ - show: true, - foo: 'bar', - template: compile('{{#if view.show}}{{#if view.foo}}{{view.foo}}{{/if}}{{/if}}') - }); - - run(function() { view.append(); }); - - equal(view.$().text(), 'bar'); - - run(function() { - view.set('foo', 'baz'); // schedule render of simple bound - view.set('show', false); // destroy tree - }); - - equal(view.$().text(), ''); - - run(function() { - view.destroy(); - }); -}); - QUnit.test('remove removes an element from the DOM', function() { willDestroyCalled = 0;
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/views/view/child_views_test.js
@@ -1,172 +0,0 @@ -import run from 'ember-metal/run_loop'; -import EmberView from 'ember-views/views/view'; -import Component from 'ember-htmlbars/component'; -import { compile } from 'ember-template-compiler'; -import { A as emberA } from 'ember-runtime/system/native_array'; - -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; -import { setOwner } from 'container/owner'; - -var originalViewKeyword; -var parentView, childView; - -import { test, testModule } from 'internal-test-helpers/tests/skip-if-glimmer'; - -testModule('tests/views/view/child_views_tests.js', { - setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); - childView = EmberView.create({ - template: compile('ber') - }); - - parentView = EmberView.create({ - template: compile('Em{{view view.childView}}'), - childView: childView - }); - }, - - teardown() { - run(function() { - parentView.destroy(); - childView.destroy(); - }); - resetKeyword('view', originalViewKeyword); - } -}); - -// no parent element, buffer, no element -// parent element - -// no parent element, no buffer, no element -test('should render an inserted child view when the child is inserted before a DOM element is created', function() { - run(function() { - parentView.append(); - }); - - equal(parentView.$().text(), 'Ember', 'renders the child view after the parent view'); -}); - -test('should not duplicate childViews when rerendering', function() { - var InnerView = EmberView.extend(); - var InnerView2 = EmberView.extend(); - - var MiddleView = EmberView.extend({ - innerViewClass: InnerView, - innerView2Class: InnerView2, - template: compile('{{view view.innerViewClass}}{{view view.innerView2Class}}') - }); - - var outerView = EmberView.create({ - middleViewClass: MiddleView, - template: compile('{{view view.middleViewClass viewName="middle"}}') - }); - - run(function() { - outerView.append(); - }); - - equal(outerView.get('middle.childViews.length'), 2, 'precond middle has 2 child views rendered to buffer'); - - run(function() { - outerView.middle.rerender(); - }); - - equal(outerView.get('middle.childViews.length'), 2, 'middle has 2 child views rendered to buffer'); - - run(function() { - outerView.destroy(); - }); -}); - -test('should remove childViews inside {{if}} on destroy', function() { - var outerView = EmberView.extend({ - component: 'my-thing', - value: false, - template: compile(` - {{#if view.value}} - {{component view.component value=view.value}} - {{/if}} - `) - }).create(); - - setOwner(outerView, { - lookup() { - return { - componentFor() { - return Component.extend(); - }, - - layoutFor() { - return null; - } - }; - } - }); - - run(outerView, 'append'); - run(outerView, 'set', 'value', true); - - equal(outerView.get('childViews.length'), 1); - - run(outerView, 'set', 'value', false); - - equal(outerView.get('childViews.length'), 0, 'expected no views to be leaked'); - - run(function() { - outerView.destroy(); - }); -}); - -test('should remove childViews inside {{each}} on destroy', function() { - var outerView = EmberView.extend({ - component: 'my-thing', - init() { - this._super(...arguments); - this.value = false; - }, - template: compile(` - {{#if view.value}} - {{#each view.data as |item|}} - {{component view.component value=item.value}} - {{/each}} - {{/if}} - `) - }).create(); - - setOwner(outerView, { - lookup() { - return { - componentFor() { - return Component.extend(); - }, - - layoutFor() { - return null; - } - }; - } - }); - - run(outerView, 'append'); - - equal(outerView.get('childViews.length'), 0); - - run(outerView, 'set', 'data', emberA([ - { id: 1, value: new Date() }, - { id: 2, value: new Date() } - ])); - - equal(outerView.get('childViews.length'), 0); - - run(outerView, 'set', 'value', true); - equal(outerView.get('childViews.length'), 2); - - run(outerView, 'set', 'value', false); - - equal(outerView.get('childViews.length'), 0, 'expected no views to be leaked'); - - run(function() { - outerView.destroy(); - }); -});
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/views/view/create_child_view_test.js
@@ -4,15 +4,12 @@ import EmberView from 'ember-views/views/view'; import { on } from 'ember-metal/events'; import { observer } from 'ember-metal/mixin'; -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; import { getOwner, OWNER } from 'container/owner'; -var view, myViewClass, newView, owner, originalViewKeyword; +var view, myViewClass, newView, owner; QUnit.module('EmberView#createChildView', { setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); owner = {}; view = EmberView.create({ [OWNER]: owner @@ -26,7 +23,6 @@ QUnit.module('EmberView#createChildView', { view.destroy(); if (newView) { newView.destroy(); } }); - resetKeyword('view', originalViewKeyword); } });
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/views/view/create_element_test.js
@@ -3,20 +3,13 @@ import run from 'ember-metal/run_loop'; import EmberView from 'ember-views/views/view'; import { compile } from 'ember-htmlbars-template-compiler'; -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; - -var view, originalViewKeyword; +var view; QUnit.module('Ember.View#createElement', { - setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); - }, teardown() { run(function() { view.destroy(); }); - resetKeyword('view', originalViewKeyword); } });
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/views/view/destroy_element_test.js
@@ -2,21 +2,13 @@ import { get } from 'ember-metal/property_get'; import run from 'ember-metal/run_loop'; import EmberView from 'ember-views/views/view'; -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; - -var originalViewKeyword; var view; QUnit.module('EmberView#destroyElement', { - setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); - }, teardown() { run(function() { view.destroy(); }); - resetKeyword('view', originalViewKeyword); } });
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/views/view/is_visible_test.js
@@ -5,16 +5,11 @@ import run from 'ember-metal/run_loop'; import { computed } from 'ember-metal/computed'; import EmberView from 'ember-views/views/view'; -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; - var view; var warnings, originalWarn; -var originalViewKeyword; QUnit.module('EmberView#isVisible', { setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); warnings = []; originalWarn = getDebugFunction('warn'); setDebugFunction('warn', function(message, test) { @@ -28,7 +23,6 @@ QUnit.module('EmberView#isVisible', { if (view) { run(function() { view.destroy(); }); } - resetKeyword('view', originalViewKeyword); setDebugFunction('warn', originalWarn); } });
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/views/view/nearest_of_type_test.js
@@ -1,84 +0,0 @@ -import run from 'ember-metal/run_loop'; -import { Mixin as EmberMixin } from 'ember-metal/mixin'; -import View from 'ember-views/views/view'; -import { compile } from 'ember-htmlbars-template-compiler'; - -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; - -var parentView, view; -var originalViewKeyword; - -var Mixin, Parent; - -QUnit.module('View#nearest*', { - setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); - Mixin = EmberMixin.create({}); - Parent = View.extend(Mixin, { - template: compile(`{{view}}`) - }); - }, - teardown() { - run(function() { - if (parentView) { parentView.destroy(); } - if (view) { view.destroy(); } - }); - resetKeyword('view', originalViewKeyword); - } -}); - -QUnit.test('nearestOfType should find the closest view by view class', function() { - var child; - - run(function() { - parentView = Parent.create(); - parentView.appendTo('#qunit-fixture'); - }); - - child = parentView.get('childViews')[0]; - equal(child.nearestOfType(Parent), parentView, 'finds closest view in the hierarchy by class'); -}); - -QUnit.test('nearestOfType should find the closest view by mixin', function() { - var child; - - run(function() { - parentView = Parent.create(); - parentView.appendTo('#qunit-fixture'); - }); - - child = parentView.get('childViews')[0]; - equal(child.nearestOfType(Mixin), parentView, 'finds closest view in the hierarchy by class'); -}); - -QUnit.test('nearestWithProperty should search immediate parent', function() { - var childView; - - view = View.create({ - myProp: true, - template: compile('{{view}}') - }); - - run(function() { - view.appendTo('#qunit-fixture'); - }); - - childView = view.get('childViews')[0]; - equal(childView.nearestWithProperty('myProp'), view); -}); - -QUnit.test('nearestChildOf should be deprecated', function() { - var child; - - run(function() { - parentView = Parent.create(); - parentView.appendTo('#qunit-fixture'); - }); - - child = parentView.get('childViews')[0]; - expectDeprecation(function() { - child.nearestChildOf(Parent); - }, 'nearestChildOf has been deprecated.'); -}); -
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/views/view/remove_test.js
@@ -3,27 +3,19 @@ import run from 'ember-metal/run_loop'; import jQuery from 'ember-views/system/jquery'; import View from 'ember-views/views/view'; -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; - var parentView, child; -var originalViewKeyword; var view; // ....................................................... // removeFromParent() // QUnit.module('View#removeFromParent', { - setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); - }, teardown() { run(function() { if (parentView) { parentView.destroy(); } if (child) { child.destroy(); } if (view) { view.destroy(); } }); - resetKeyword('view', originalViewKeyword); } });
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/views/view/view_lifecycle_test.js
@@ -1,23 +1,17 @@ import { context } from 'ember-environment'; import run from 'ember-metal/run_loop'; -import EmberObject from 'ember-runtime/system/object'; import jQuery from 'ember-views/system/jquery'; import EmberView from 'ember-views/views/view'; import { compile } from 'ember-template-compiler'; import { registerHelper } from 'ember-htmlbars/helpers'; -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; - var originalLookup = context.lookup; -var originalViewKeyword; var lookup, view; import { test, testModule } from 'internal-test-helpers/tests/skip-if-glimmer'; QUnit.module('views/view/view_lifecycle_test - pre-render', { setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); context.lookup = lookup = {}; }, @@ -28,40 +22,9 @@ QUnit.module('views/view/view_lifecycle_test - pre-render', { }); } context.lookup = originalLookup; - resetKeyword('view', originalViewKeyword); } }); -test('should create and append a DOM element after bindings have synced', function() { - var ViewTest; - - lookup.ViewTest = ViewTest = {}; - - run(function() { - ViewTest.fakeController = EmberObject.create({ - fakeThing: 'controllerPropertyValue' - }); - - let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + - ' are binding to a global consider using a service instead.'; - - expectDeprecation(() => { - view = EmberView.create({ - fooBinding: 'ViewTest.fakeController.fakeThing', - template: compile('{{view.foo}}') - }); - }, deprecationMessage); - - ok(!view.get('element'), 'precond - does not have an element before appending'); - - // the actual render happens in the `render` queue, which is after the `sync` - // queue where the binding is synced. - view.append(); - }); - - equal(view.$().text(), 'controllerPropertyValue', 'renders and appends after bindings have synced'); -}); - QUnit.test('should throw an exception if trying to append a child before rendering has begun', function() { run(function() { view = EmberView.create(); @@ -99,16 +62,12 @@ test('should not affect rendering if destroyElement is called before initial ren }); testModule('views/view/view_lifecycle_test - in render', { - setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); - }, teardown() { if (view) { run(function() { view.destroy(); }); } - resetKeyword('view', originalViewKeyword); } }); @@ -128,25 +87,6 @@ test('rerender of top level view during rendering should throw', function() { ); }); -test('rerender of non-top level view during rendering should throw', function() { - let innerView = EmberView.create({ - template: compile('{{throw}}') - }); - registerHelper('throw', function() { - innerView.rerender(); - }); - view = EmberView.create({ - template: compile('{{view view.innerView}}'), - innerView - }); - throws( - function() { - run(view, view.appendTo, '#qunit-fixture'); - }, - /Something you did caused a view to re-render after it rendered but before it was inserted into the DOM./, - 'expected error was not raised' - ); -}); QUnit.module('views/view/view_lifecycle_test - hasElement', { teardown() {
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember-views/tests/views/view_test.js
@@ -4,20 +4,13 @@ import jQuery from 'ember-views/system/jquery'; import EmberView 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'; - -var view, originalViewKeyword; +var view; QUnit.module('Ember.View', { - setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); - }, teardown() { run(function() { view.destroy(); }); - resetKeyword('view', originalViewKeyword); } }); @@ -86,53 +79,3 @@ test('should re-render if the context is changed', function() { equal(jQuery('#qunit-fixture #template-context-test').text(), 'bang baz', 're-renders the view with the updated context'); }); - -test('propagates dependent-key invalidated sets upstream', function() { - view = EmberView.create({ - parentProp: 'parent-value', - template: compile('{{view view.childView childProp=view.parentProp}}'), - childView: EmberView.create({ - template: compile('child template'), - childProp: 'old-value' - }) - }); - - run(view, view.append); - - equal(view.get('parentProp'), 'parent-value', 'precond - parent value is there'); - var childView = view.get('childView'); - - run(function() { - childView.set('childProp', 'new-value'); - }); - - equal(view.get('parentProp'), 'new-value', 'new value is propagated across template'); -}); - -test('propagates dependent-key invalidated bindings upstream', function() { - view = EmberView.create({ - parentProp: 'parent-value', - template: compile('{{view view.childView childProp=view.parentProp}}'), - childView: EmberView.extend({ - template: compile('child template'), - childProp: computed('dependencyProp', { - get(key) { - return this.get('dependencyProp'); - }, - set(key, value) { - // Avoid getting stomped by the template attrs - return this.get('dependencyProp'); - } - }), - dependencyProp: 'old-value' - }).create() - }); - - run(view, view.append); - - equal(view.get('parentProp'), 'parent-value', 'precond - parent value is there'); - var childView = view.get('childView'); - run(() => childView.set('dependencyProp', 'new-value')); - equal(childView.get('childProp'), 'new-value', 'pre-cond - new value is propagated to CP'); - equal(view.get('parentProp'), 'new-value', 'new value is propagated across template'); -});
true
Other
emberjs
ember.js
7c6574ffdfa61d879cbdbac28c025601e10249d4.json
Remove view keyword
packages/ember/tests/routing/basic_test.js
@@ -25,7 +25,6 @@ import { addObserver } from 'ember-metal/observer'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; import { test, asyncTest } from 'internal-test-helpers/tests/skip-if-glimmer'; - var trim = jQuery.trim; var Router, App, router, registry, container, originalLoggerError; @@ -2247,6 +2246,76 @@ test('The template is not re-rendered when the route\'s context changes', functi equal(insertionCount, 1, 'view should still have inserted only once'); }); +test('The template is not re-rendered when two routes present the exact same template & controller', function() { + Router.map(function() { + this.route('first'); + this.route('second'); + this.route('third'); + this.route('fourth'); + }); + + // Note add a component to test insertion + + let insertionCount = 0; + App.XInputComponent = Component.extend({ + didInsertElement() { + insertionCount += 1; + } + }); + + App.SharedRoute = Route.extend({ + setupController(controller) { + this.controllerFor('shared').set('message', 'This is the ' + this.routeName + ' message'); + }, + + renderTemplate(controller, context) { + this.render('shared', { controller: 'shared' }); + } + }); + + App.FirstRoute = App.SharedRoute.extend(); + App.SecondRoute = App.SharedRoute.extend(); + App.ThirdRoute = App.SharedRoute.extend(); + App.FourthRoute = App.SharedRoute.extend(); + + App.SharedController = Controller.extend(); + + setTemplate('shared', compile( + '<p>{{message}}{{x-input}}</p>' + )); + + bootApplication(); + + handleURL('/first'); + + equal(jQuery('p', '#qunit-fixture').text(), 'This is the first message'); + equal(insertionCount, 1, 'expected one assertion'); + + // Transition by URL + handleURL('/second'); + + equal(jQuery('p', '#qunit-fixture').text(), 'This is the second message'); + equal(insertionCount, 1, 'expected one assertion'); + + // Then transition directly by route name + run(function() { + router.transitionTo('third').then(function(value) { + ok(true, 'expected transition'); + }, function(reason) { + ok(false, 'unexpected transition failure: ', QUnit.jsDump.parse(reason)); + }); + }); + + equal(jQuery('p', '#qunit-fixture').text(), 'This is the third message'); + equal(insertionCount, 1, 'expected one assertion'); + + // Lastly transition to a different view, with the same controller and template + handleURL('/fourth'); + equal(insertionCount, 1, 'expected one assertion'); + + equal(jQuery('p', '#qunit-fixture').text(), 'This is the fourth message'); +}); + QUnit.test('ApplicationRoute with model does not proxy the currentPath', function() { var model = {}; var currentPath;
true