Skip to content

Commit

Permalink
Revert "feat: Assert "Cannot pass QPs object in @models and @query at…
Browse files Browse the repository at this point in the history
… same time"

This reverts commit fc7cb2d.
  • Loading branch information
Alonski committed Oct 5, 2019
1 parent fc7cb2d commit c7404ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
20 changes: 6 additions & 14 deletions packages/@ember/-internals/glimmer/lib/components/link-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

import { alias, computed } from '@ember/-internals/metal';
import { isQueryParams } from '@ember/-internals/routing/lib/system/query_params';
import { isSimpleClick } from '@ember/-internals/views';
import { assert, warn } from '@ember/debug';
import { flaggedInstrument } from '@ember/instrumentation';
Expand Down Expand Up @@ -839,21 +838,14 @@ const LinkComponent = EmberComponent.extend({
)
);

if (this.query === UNDEFINED) {
let { _models: models } = this;
if (models.length > 0) {
let lastModel = models[models.length - 1];
let { _models: models } = this;
if (models.length > 0) {
let lastModel = models[models.length - 1];

if (typeof lastModel === 'object' && lastModel !== null && lastModel.isQueryParams) {
this.query = lastModel.values;
models.pop();
}
if (typeof lastModel === 'object' && lastModel !== null && lastModel.isQueryParams) {
this.query = lastModel.values;
models.pop();
}
} else {
assert(
'Cannot pass a QueryParams object in @models and @query at the same time',
!(this.models.length === 0 || isQueryParams(this.models[this.models.length - 1]))
);
}

return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { Option } from '@glimmer/interfaces';

export default class QueryParams {
values: null | object;
isQueryParams = true;
constructor(values: Option<object> = null) {
constructor(values = null) {
this.values = values;
}
}

export function isQueryParams(obj: unknown): obj is QueryParams {
return typeof obj === 'object' && obj !== null && obj['isQueryParams'] === true;
}

0 comments on commit c7404ca

Please sign in to comment.