Skip to content

Commit 0dd69ec

Browse files
committed
svelte
1 parent 93479b8 commit 0dd69ec

File tree

2 files changed

+51
-41
lines changed

2 files changed

+51
-41
lines changed
Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,74 @@
11
import { assert, deprecate } from '@ember/debug';
22
import EmberError from '@ember/error';
3+
import { PARTIALS } from '@ember/deprecated-features';
34

45
function parseUnderscoredName(templateName) {
5-
let nameParts = templateName.split('/');
6-
let lastPart = nameParts[nameParts.length - 1];
6+
if (PARTIALS) {
7+
let nameParts = templateName.split('/');
8+
let lastPart = nameParts[nameParts.length - 1];
79

8-
nameParts[nameParts.length - 1] = `_${lastPart}`;
10+
nameParts[nameParts.length - 1] = `_${lastPart}`;
911

10-
return nameParts.join('/');
12+
return nameParts.join('/');
13+
}
1114
}
1215

1316
export default function lookupPartial(templateName, owner) {
14-
deprecate(
15-
`The use of \`{{partial}}\` is deprecated, please refactor the "${templateName}" partial to a component`,
16-
false,
17-
{
18-
id: 'ember-views.partial',
19-
until: '4.0.0',
20-
url: 'https://deprecations.emberjs.com/v3.x#toc_ember-views-partial',
21-
}
22-
);
17+
if (PARTIALS) {
18+
deprecate(
19+
`The use of \`{{partial}}\` is deprecated, please refactor the "${templateName}" partial to a component`,
20+
false,
21+
{
22+
id: 'ember-views.partial',
23+
until: '4.0.0',
24+
url: 'https://deprecations.emberjs.com/v3.x#toc_ember-views-partial',
25+
}
26+
);
2327

24-
if (templateName == null) {
25-
return;
26-
}
28+
if (templateName == null) {
29+
return;
30+
}
2731

28-
let template = templateFor(owner, parseUnderscoredName(templateName), templateName);
32+
let template = templateFor(owner, parseUnderscoredName(templateName), templateName);
2933

30-
assert(`Unable to find partial with name "${templateName}"`, Boolean(template));
34+
assert(`Unable to find partial with name "${templateName}"`, Boolean(template));
3135

32-
return template;
36+
return template;
37+
}
3338
}
3439

3540
export function hasPartial(name, owner) {
36-
if (!owner) {
37-
throw new EmberError(
38-
'Container was not found when looking up a views template. ' +
39-
'This is most likely due to manually instantiating an Ember.View. ' +
40-
'See: http://git.io/EKPpnA'
41+
if (PARTIALS) {
42+
if (!owner) {
43+
throw new EmberError(
44+
'Container was not found when looking up a views template. ' +
45+
'This is most likely due to manually instantiating an Ember.View. ' +
46+
'See: http://git.io/EKPpnA'
47+
);
48+
}
49+
50+
return (
51+
owner.hasRegistration(`template:${parseUnderscoredName(name)}`) ||
52+
owner.hasRegistration(`template:${name}`)
4153
);
4254
}
43-
44-
return (
45-
owner.hasRegistration(`template:${parseUnderscoredName(name)}`) ||
46-
owner.hasRegistration(`template:${name}`)
47-
);
4855
}
4956

5057
function templateFor(owner, underscored, name) {
51-
if (!name) {
52-
return;
53-
}
54-
assert(`templateNames are not allowed to contain periods: ${name}`, name.indexOf('.') === -1);
58+
if (PARTIALS) {
59+
if (!name) {
60+
return;
61+
}
62+
assert(`templateNames are not allowed to contain periods: ${name}`, name.indexOf('.') === -1);
5563

56-
if (!owner) {
57-
throw new EmberError(
58-
'Container was not found when looking up a views template. ' +
59-
'This is most likely due to manually instantiating an Ember.View. ' +
60-
'See: http://git.io/EKPpnA'
61-
);
62-
}
64+
if (!owner) {
65+
throw new EmberError(
66+
'Container was not found when looking up a views template. ' +
67+
'This is most likely due to manually instantiating an Ember.View. ' +
68+
'See: http://git.io/EKPpnA'
69+
);
70+
}
6371

64-
return owner.lookup(`template:${underscored}`) || owner.lookup(`template:${name}`);
72+
return owner.lookup(`template:${underscored}`) || owner.lookup(`template:${name}`);
73+
}
6574
}

packages/@ember/deprecated-features/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ export const APP_CTRL_ROUTER_PROPS = !!'3.10.0-beta.1';
1515
export const FUNCTION_PROTOTYPE_EXTENSIONS = !!'3.11.0-beta.1';
1616
export const MOUSE_ENTER_LEAVE_MOVE_EVENTS = !!'3.13.0-beta.1';
1717
export const EMBER_COMPONENT_IS_VISIBLE = !!'3.15.0-beta.1';
18+
export const PARTIALS = !!'3.15.0-beta.1';

0 commit comments

Comments
 (0)