Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function readUnwrappedModel(object) {
if (isStream(object)) {
let result = object.value();
// If the path is exactly `controller` then we don't unwrap it.
if (object.label !== 'controller') {
while (ControllerMixin.detect(result)) {
result = get(result, 'model');
}
}
return result;
} else {
return object;
}
}
export function readUnwrappedModel(object) {
if (isStream(object)) {
var result = object.value();
// If the path is exactly `controller` then we don't unwrap it.
if (object.label !== 'controller') {
while (ControllerMixin.detect(result)) {
result = get(result, 'model');
}
}
return result;
} else {
return object;
}
}
_assertArrayLike: function(content) {
Ember.assert(fmt("The value that #each loops over must be an Array. You " +
"passed %@, but it should have been an ArrayController",
[content.constructor]),
!ControllerMixin.detect(content) ||
(content && content.isGenerated) ||
content instanceof ArrayController);
Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@",
[(ControllerMixin.detect(content) &&
content.get('model') !== undefined) ?
fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]),
EmberArray.detect(content));
},
_assertArrayLike: function(content) {
Ember.assert(fmt("The value that #each loops over must be an Array. You " +
"passed %@, but it should have been an ArrayController",
[content.constructor]),
!ControllerMixin.detect(content) ||
(content && content.isGenerated) ||
content instanceof ArrayController);
Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@",
[(ControllerMixin.detect(content) &&
content.get('model') !== undefined) ?
fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]),
EmberArray.detect(content));
},
if (attrs.disabledWhen) {
this.set('disabled', attrs.disabledWhen);
}
if (!this[HAS_BLOCK]) {
this.set('linkTitle', params.shift());
}
if (attrs.loadingClass) {
set(this, 'loadingClass', attrs.loadingClass);
}
for (let i = 0; i < params.length; i++) {
var value = params[i];
while (ControllerMixin.detect(value)) {
Ember.deprecate(
'Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. ' +
(attrs[RELATED_VIEW] ? 'Please update `' + attrs[RELATED_VIEW] + '` to use `{{link-to "post" someController.model}}` instead.' : ''),
false,
{ id: 'ember-routing-views.controller-wrapped-param', until: '3.0.0' }
);
value = value.get('model');
}
params[i] = value;
}
let targetRouteName;
let models = [];
targetRouteName = this._computeRouteNameWithQueryParams(params[0]);
_assertArrayLike: function(content) {
Ember.assert(fmt("The value that #each loops over must be an Array. You " +
"passed %@, but it should have been an ArrayController",
[content.constructor]),
!ControllerMixin.detect(content) ||
(content && content.isGenerated) ||
content instanceof ArrayController);
Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@",
[(ControllerMixin.detect(content) &&
content.get('model') !== undefined) ?
fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]),
EmberArray.detect(content));
},
if (shouldEscape) {
hash.layout = inlineEscapedLinkTo;
} else {
hash.layout = inlineUnescapedLinkTo;
}
hash.linkTitle = linkTitle;
}
for (var i = 0; i < params.length; i++) {
if (isStream(params[i])) {
var lazyValue = params[i];
if (!lazyValue._isController) {
while (ControllerMixin.detect(lazyValue.value())) {
lazyValue = lazyValue.get('model');
}
}
params[i] = lazyValue;
}
}
hash.params = params;
options.helperName = options.helperName || 'link-to';
return env.helpers.view.helperFunction.call(this, [LinkView], hash, options, env);
}
_getModels(params) {
let modelCount = params.length - 1;
let models = new Array(modelCount);
for (let i = 0; i < modelCount; i++) {
let value = params[i + 1];
while (ControllerMixin.detect(value)) {
deprecate(
'Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. ' +
(this.parentView ? 'Please update `' + this.parentView + '` to use `{{link-to "post" someController.model}}` instead.' : ''),
false,
{ id: 'ember-routing-views.controller-wrapped-param', until: '3.0.0' }
);
value = value.get('model');
}
models[i] = value;
}
return models;
},
_assertArrayLike: function(content) {
Ember.assert(fmt("The value that #each loops over must be an Array. You " +
"passed %@, but it should have been an ArrayController",
[content.constructor]),
!ControllerMixin.detect(content) ||
(content && content.isGenerated) ||
content instanceof ArrayController);
Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@",
[(ControllerMixin.detect(content) &&
content.get('model') !== undefined) ?
fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]),
EmberArray.detect(content));
},