Skip to content

Commit

Permalink
svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinJoyce committed Oct 24, 2019
1 parent 93479b8 commit 0dd69ec
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 41 deletions.
91 changes: 50 additions & 41 deletions packages/@ember/-internals/views/lib/system/lookup_partial.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,74 @@
import { assert, deprecate } from '@ember/debug';
import EmberError from '@ember/error';
import { PARTIALS } from '@ember/deprecated-features';

function parseUnderscoredName(templateName) {
let nameParts = templateName.split('/');
let lastPart = nameParts[nameParts.length - 1];
if (PARTIALS) {
let nameParts = templateName.split('/');
let lastPart = nameParts[nameParts.length - 1];

nameParts[nameParts.length - 1] = `_${lastPart}`;
nameParts[nameParts.length - 1] = `_${lastPart}`;

return nameParts.join('/');
return nameParts.join('/');
}
}

export default function lookupPartial(templateName, owner) {
deprecate(
`The use of \`{{partial}}\` is deprecated, please refactor the "${templateName}" partial to a component`,
false,
{
id: 'ember-views.partial',
until: '4.0.0',
url: 'https://deprecations.emberjs.com/v3.x#toc_ember-views-partial',
}
);
if (PARTIALS) {
deprecate(
`The use of \`{{partial}}\` is deprecated, please refactor the "${templateName}" partial to a component`,
false,
{
id: 'ember-views.partial',
until: '4.0.0',
url: 'https://deprecations.emberjs.com/v3.x#toc_ember-views-partial',
}
);

if (templateName == null) {
return;
}
if (templateName == null) {
return;
}

let template = templateFor(owner, parseUnderscoredName(templateName), templateName);
let template = templateFor(owner, parseUnderscoredName(templateName), templateName);

assert(`Unable to find partial with name "${templateName}"`, Boolean(template));
assert(`Unable to find partial with name "${templateName}"`, Boolean(template));

return template;
return template;
}
}

export function hasPartial(name, owner) {
if (!owner) {
throw new EmberError(
'Container was not found when looking up a views template. ' +
'This is most likely due to manually instantiating an Ember.View. ' +
'See: http://git.io/EKPpnA'
if (PARTIALS) {
if (!owner) {
throw new EmberError(
'Container was not found when looking up a views template. ' +
'This is most likely due to manually instantiating an Ember.View. ' +
'See: http://git.io/EKPpnA'
);
}

return (
owner.hasRegistration(`template:${parseUnderscoredName(name)}`) ||
owner.hasRegistration(`template:${name}`)
);
}

return (
owner.hasRegistration(`template:${parseUnderscoredName(name)}`) ||
owner.hasRegistration(`template:${name}`)
);
}

function templateFor(owner, underscored, name) {
if (!name) {
return;
}
assert(`templateNames are not allowed to contain periods: ${name}`, name.indexOf('.') === -1);
if (PARTIALS) {
if (!name) {
return;
}
assert(`templateNames are not allowed to contain periods: ${name}`, name.indexOf('.') === -1);

if (!owner) {
throw new EmberError(
'Container was not found when looking up a views template. ' +
'This is most likely due to manually instantiating an Ember.View. ' +
'See: http://git.io/EKPpnA'
);
}
if (!owner) {
throw new EmberError(
'Container was not found when looking up a views template. ' +
'This is most likely due to manually instantiating an Ember.View. ' +
'See: http://git.io/EKPpnA'
);
}

return owner.lookup(`template:${underscored}`) || owner.lookup(`template:${name}`);
return owner.lookup(`template:${underscored}`) || owner.lookup(`template:${name}`);
}
}
1 change: 1 addition & 0 deletions packages/@ember/deprecated-features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export const APP_CTRL_ROUTER_PROPS = !!'3.10.0-beta.1';
export const FUNCTION_PROTOTYPE_EXTENSIONS = !!'3.11.0-beta.1';
export const MOUSE_ENTER_LEAVE_MOVE_EVENTS = !!'3.13.0-beta.1';
export const EMBER_COMPONENT_IS_VISIBLE = !!'3.15.0-beta.1';
export const PARTIALS = !!'3.15.0-beta.1';

0 comments on commit 0dd69ec

Please sign in to comment.