Skip to content

Commit 96cb49d

Browse files
committed
[FEATURE ember-glimmer-angle-bracket-built-ins]
Remove `{{dash-rule}}` for curly invocations.
1 parent 2541268 commit 96cb49d

File tree

3 files changed

+58
-14
lines changed

3 files changed

+58
-14
lines changed

packages/@ember/-internals/glimmer/lib/syntax.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { OwnedTemplateMeta } from '@ember/-internals/views';
2+
import { EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS } from '@ember/canary-features';
23
import { assert } from '@ember/debug';
34
import { CompilableBlock } from '@glimmer/interfaces';
45
import { Macros, OpcodeBuilder } from '@glimmer/opcode-compiler';
@@ -26,7 +27,8 @@ function refineInlineSyntax(
2627
builder.referrer.owner.hasRegistration(`helper:${name}`)
2728
)
2829
);
29-
if (name.indexOf('-') === -1) {
30+
31+
if (!EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS && name.indexOf('-') === -1) {
3032
return false;
3133
}
3234

@@ -48,7 +50,7 @@ function refineBlockSyntax(
4850
inverse: Option<CompilableBlock>,
4951
builder: OpcodeBuilder<OwnedTemplateMeta>
5052
) {
51-
if (name.indexOf('-') === -1) {
53+
if (!EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS && name.indexOf('-') === -1) {
5254
return false;
5355
}
5456

@@ -97,11 +99,14 @@ export function populateMacros(macros: Macros) {
9799
inlines.add('outlet', outletMacro);
98100
inlines.add('mount', mountMacro);
99101
inlines.add('input', inputMacro);
100-
inlines.add('textarea', textAreaMacro);
101102
inlines.addMissing(refineInlineSyntax);
102103
blocks.add('let', blockLetMacro);
103104
blocks.addMissing(refineBlockSyntax);
104105

106+
if (!EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS) {
107+
inlines.add('textarea', textAreaMacro);
108+
}
109+
105110
for (let i = 0; i < experimentalMacros.length; i++) {
106111
let macro = experimentalMacros[i];
107112
macro(blocks, inlines);
Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
import { OwnedTemplateMeta } from '@ember/-internals/views';
22
import { EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS } from '@ember/canary-features';
3+
import { DEBUG } from '@glimmer/env';
34
import { Option } from '@glimmer/interfaces';
45
import { OpcodeBuilder } from '@glimmer/opcode-compiler';
6+
import { unreachable } from '@glimmer/util';
57
import * as WireFormat from '@glimmer/wire-format';
68
import { wrapComponentClassAttribute } from '../utils/bindings';
79
import { hashToArgs } from './utils';
810

9-
export function textAreaMacro(
10-
_name: string,
11+
export let textAreaMacro: (
12+
name: string,
1113
params: Option<WireFormat.Core.Params>,
1214
hash: Option<WireFormat.Core.Hash>,
1315
builder: OpcodeBuilder<OwnedTemplateMeta>
14-
) {
15-
let definition = builder.compiler['resolver'].lookupComponentDefinition(
16-
EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS ? 'textarea' : '-text-area',
17-
builder.referrer
18-
);
19-
wrapComponentClassAttribute(hash);
20-
builder.component.static(definition!, [params || [], hashToArgs(hash), null, null]);
21-
return true;
16+
) => boolean;
17+
18+
if (EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS) {
19+
if (DEBUG) {
20+
textAreaMacro = () => {
21+
throw unreachable();
22+
};
23+
}
24+
} else {
25+
textAreaMacro = function textAreaMacro(
26+
_name: string,
27+
params: Option<WireFormat.Core.Params>,
28+
hash: Option<WireFormat.Core.Hash>,
29+
builder: OpcodeBuilder<OwnedTemplateMeta>
30+
) {
31+
let definition = builder.compiler['resolver'].lookupComponentDefinition(
32+
'-text-area',
33+
builder.referrer
34+
);
35+
wrapComponentClassAttribute(hash);
36+
builder.component.static(definition!, [params || [], hashToArgs(hash), null, null]);
37+
return true;
38+
};
2239
}

packages/@ember/-internals/glimmer/tests/integration/components/curly-components-test.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,29 @@ moduleFor(
12811281
this.assertText('some-prop some-component');
12821282
}
12831283

1284-
['@test component without dash is not looked up']() {
1284+
['@feature(ember-glimmer-angle-bracket-built-ins) component without dash is looked up']() {
1285+
this.registerComponent('somecomponent', {
1286+
template: 'somecomponent',
1287+
});
1288+
1289+
this.render('{{somecomponent}}', {
1290+
somecomponent: 'notsomecomponent',
1291+
});
1292+
1293+
this.assertText('somecomponent');
1294+
1295+
this.assertStableRerender();
1296+
1297+
runTask(() => this.context.set('somecomponent', 'not not notsomecomponent'));
1298+
1299+
this.assertText('somecomponent');
1300+
1301+
runTask(() => this.context.set('somecomponent', 'notsomecomponent'));
1302+
1303+
this.assertText('somecomponent');
1304+
}
1305+
1306+
['@feature(!ember-glimmer-angle-bracket-built-ins) component without dash is not looked up']() {
12851307
this.registerComponent('somecomponent', {
12861308
template: 'somecomponent',
12871309
});

0 commit comments

Comments
 (0)