Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[CLEANUP] Remove deprecated 'POSITIONAL_PARAM_CONFLICT' #17319

Merged
merged 1 commit into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions packages/@ember/-internals/glimmer/lib/component-managers/curly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { get } from '@ember/-internals/metal';
import { getOwner } from '@ember/-internals/owner';
import { guidFor } from '@ember/-internals/utils';
import { addChildView, OwnedTemplateMeta, setViewElement } from '@ember/-internals/views';
import { assert, deprecate } from '@ember/debug';
import { POSITIONAL_PARAM_CONFLICT } from '@ember/deprecated-features';
import { assert } from '@ember/debug';
import { _instrumentStart } from '@ember/instrumentation';
import { assign } from '@ember/polyfills';
import { DEBUG } from '@glimmer/env';
Expand Down Expand Up @@ -182,19 +181,16 @@ export default class CurlyComponentManager
const count = Math.min(positionalParams.length, args.positional.length);
named = {};
assign(named, args.named.capture().map);
if (POSITIONAL_PARAM_CONFLICT) {
for (let i = 0; i < count; i++) {
const name = positionalParams[i];
deprecate(
`You cannot specify both a positional param (at position ${i}) and the hash argument \`${name}\`.`,
!args.named.has(name),
{
id: 'ember-glimmer.positional-param-conflict',
until: '3.5.0',
}
);
named[name] = args.positional.at(i);
}

for (let i = 0; i < count; i++) {
const name = positionalParams[i];

assert(
`You cannot specify both a positional param (at position ${i}) and the hash argument \`${name}\`.`,
!args.named.has(name)
);

named[name] = args.positional.at(i);
}
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,130 +328,6 @@ moduleFor(
this.assertText('Hi Max 9');
}

['@test nested components positional parameters override named parameters [DEPRECATED]']() {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['name', 'age'],
}),
template: '{{name}} {{age}}',
});

expectDeprecation(() => {
this.render(
'{{component (component (component "-looked-up" "Sergio" 29) name="Marvin" age=21)}}'
);
}, 'You cannot specify both a positional param (at position 1) and the hash argument `age`.');

this.assertText('Sergio 29');

this.runTask(() => this.rerender());

this.assertText('Sergio 29');
}

['@test nested components with positional params at outer layer are override hash parameters [DEPRECATED]']() {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['greeting', 'name', 'age'],
}),
template: '{{greeting}} {{name}} {{age}}',
});

expectDeprecation(() => {
this.render(
strip`
{{#with (component "-looked-up" "Hola" "Dolores" 33) as |first|}}
{{#with (component first greeting="Hej" name="Sigmundur") as |second|}}
{{component second greeting=model.greeting}}
{{/with}}
{{/with}}`,
{
model: {
greeting: 'Hodi',
},
}
);
}, 'You cannot specify both a positional param (at position 1) and the hash argument `name`.');

this.assertText('Hola Dolores 33');

this.runTask(() => this.rerender());

this.assertText('Hola Dolores 33');
}

['@test nested components with positional params at middle layer partially override hash parameters [DEPRECATED]']() {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['greeting', 'name', 'age'],
}),

template: '{{greeting}} {{name}} {{age}}',
});

expectDeprecation(() => {
this.render(
strip`
{{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}
{{#with (component first "Hej" "Sigmundur") as |second|}}
{{component second greeting=model.greeting}}
{{/with}}
{{/with}}`,
{
model: {
greeting: 'Hodi',
},
}
);
}, 'You cannot specify both a positional param (at position 0) and the hash argument `greeting`.');

this.assertText('Hej Sigmundur 33');

this.runTask(() => this.rerender());

this.assertText('Hej Sigmundur 33');
}

['@test nested components with positional params at invocation override earlier hash parameters [DEPRECATED]']() {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['greeting', 'name', 'age'],
}),

template: '{{greeting}} {{name}} {{age}}',
});

expectDeprecation(() => {
this.render(
strip`
{{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}
{{#with (component first greeting="Hej" name="Sigmundur") as |second|}}
{{component second model.greeting}}
{{/with}}
{{/with}}`,
{
model: {
greeting: 'Hodi',
},
}
);
}, 'You cannot specify both a positional param (at position 0) and the hash argument `greeting`.');

this.assertText('Hodi Sigmundur 33');

this.runTask(() => this.rerender());

this.assertText('Hodi Sigmundur 33');

this.runTask(() => this.context.set('model.greeting', 'Kaixo'));

this.assertText('Kaixo Sigmundur 33');

this.runTask(() => this.context.set('model', { greeting: 'Hodi' }));

this.assertText('Hodi Sigmundur 33');
}

['@test nested components overwrite hash parameters']() {
this.registerComponent('-looked-up', {
template: '{{greeting}} {{name}} {{age}}',
Expand Down Expand Up @@ -581,21 +457,6 @@ moduleFor(
this.assertText('Inner 28');
}

['@test conflicting positional and hash parameters trigger a deprecation if in the same component context [DEPRECATED]']() {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['name'],
}),
template: '{{greeting}} {{name}}',
});

expectDeprecation(() => {
this.render(
'{{component (component "-looked-up" "Hodari" name="Sergio") "Hodari" greeting="Hodi"}}'
);
}, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.');
}

['@test conflicting positional and hash parameters does not raise an assertion if rerendered']() {
// In some cases, rerendering with a positional param used to cause an
// assertion. This test checks it does not.
Expand Down Expand Up @@ -627,27 +488,6 @@ moduleFor(
this.assertText('Hodi Hodari');
}

['@test conflicting positional and hash parameters trigger a deprecation [DEPRECATED]']() {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['name'],
}),
template: '{{greeting}} {{name}}',
});

expectDeprecation(() => {
this.render(
'{{component (component "-looked-up" "Hodari") name="Sergio" greeting="Hodi"}}'
);
}, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.');

this.assertText('Hodi Hodari');

this.runTask(() => this.rerender());

this.assertText('Hodi Hodari');
}

['@test component with dynamic component name resolving to undefined, then an existing component']() {
this.registerComponent('foo-bar', { template: 'hello {{name}}' });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,7 @@ moduleFor(
template: '{{name}}',
});

expectDeprecation(() => {
expectAssertion(() => {
this.render('{{sample-component notMyName name=myName}}', {
myName: 'Quint',
notMyName: 'Sergio',
Expand Down
1 change: 0 additions & 1 deletion packages/@ember/deprecated-features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export const SEND_ACTION = !!'3.4.0';
export const EMBER_EXTEND_PROTOTYPES = !!'3.2.0-beta.5';
export const RUN_SYNC = !!'3.0.0-beta.4';
export const LOGGER = !!'3.2.0-beta.1';
export const POSITIONAL_PARAM_CONFLICT = !!'3.1.0-beta.1';
export const ARRAY_AT_EACH = !!'3.1.0-beta.1';
export const MAP = !!'3.3.0-beta.1';
export const ORDERED_SET = !!'3.3.0-beta.1';
Expand Down