ember-source 7.1.0-beta.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-metadata.json +3 -3
- package/dist/dev/packages/@ember/-internals/glimmer/index.js +5 -5
- package/dist/dev/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +1 -1
- package/dist/dev/packages/@ember/application/index.js +1 -1
- package/dist/dev/packages/@ember/application/instance.js +1 -1
- package/dist/dev/packages/@ember/array/index.js +4 -0
- package/dist/dev/packages/@ember/component/helper.js +1 -1
- package/dist/dev/packages/@ember/component/index.js +9 -3
- package/dist/dev/packages/@ember/engine/index.js +1 -1
- package/dist/dev/packages/@ember/helper/index.js +4 -23
- package/dist/dev/packages/@ember/modifier/on.js +1 -1
- package/dist/dev/packages/@ember/object/index.js +22 -17
- package/dist/dev/packages/@ember/renderer/index.js +1 -1
- package/dist/dev/packages/@ember/routing/index.js +8 -4
- package/dist/dev/packages/@ember/routing/route.js +1 -1
- package/dist/dev/packages/@ember/routing/router-service.js +19 -12
- package/dist/dev/packages/@ember/template-compiler/lib/compile-options.js +3 -3
- package/dist/dev/packages/@glimmer/runtime/index.js +4 -4
- package/dist/dev/packages/ember/version.js +1 -1
- package/dist/dev/packages/shared-chunks/{element-DQJOvSlQ.js → element-Cf3hqNOD.js} +2 -0
- package/dist/dev/packages/shared-chunks/{get-D5b5QlqE.js → get-BehtPmsu.js} +30 -33
- package/dist/dev/packages/shared-chunks/{hash-BRRFQJ99.js → hash-BTwOuDGQ.js} +15 -9
- package/dist/dev/packages/shared-chunks/{helper-Do7NCZHI.js → helper-BubrhyuN.js} +18 -6
- package/dist/dev/packages/shared-chunks/{index-CwnQYqK5.js → index-CL1zjHwo.js} +80 -102
- package/dist/dev/packages/shared-chunks/{on-BueSMv9L.js → on-BQii6ILK.js} +6 -6
- package/dist/dev/packages/shared-chunks/{or-O0eJQ4K-.js → or-BTH3yuFG.js} +1 -1
- package/dist/dev/packages/shared-chunks/{setup-registry-BC5VMvei.js → setup-registry-BQZJfq-Y.js} +2 -2
- package/dist/dev/packages/shared-chunks/{textarea-WSlUEr0y.js → textarea-lD4apgrP.js} +6 -2
- package/dist/prod/packages/@ember/-internals/glimmer/index.js +5 -5
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +1 -1
- package/dist/prod/packages/@ember/application/index.js +1 -1
- package/dist/prod/packages/@ember/application/instance.js +1 -1
- package/dist/prod/packages/@ember/array/index.js +4 -0
- package/dist/prod/packages/@ember/component/helper.js +1 -1
- package/dist/prod/packages/@ember/component/index.js +9 -3
- package/dist/prod/packages/@ember/engine/index.js +1 -1
- package/dist/prod/packages/@ember/helper/index.js +4 -23
- package/dist/prod/packages/@ember/modifier/on.js +1 -1
- package/dist/prod/packages/@ember/object/index.js +22 -17
- package/dist/prod/packages/@ember/renderer/index.js +1 -1
- package/dist/prod/packages/@ember/routing/index.js +8 -4
- package/dist/prod/packages/@ember/routing/route.js +1 -1
- package/dist/prod/packages/@ember/routing/router-service.js +19 -12
- package/dist/prod/packages/@ember/template-compiler/lib/compile-options.js +3 -3
- package/dist/prod/packages/@glimmer/runtime/index.js +4 -4
- package/dist/prod/packages/ember/version.js +1 -1
- package/dist/prod/packages/shared-chunks/{element-DUOVW5Ho.js → element-9DRa_9dO.js} +2 -0
- package/dist/prod/packages/shared-chunks/{get-t0-itmA-.js → get-Dt5L0TcU.js} +30 -33
- package/dist/prod/packages/shared-chunks/{hash-mcs3pEFO.js → hash-Dkj3I4L4.js} +15 -9
- package/dist/prod/packages/shared-chunks/{helper-DLjV2ZZW.js → helper-CN6UzshW.js} +18 -6
- package/dist/prod/packages/shared-chunks/{index-qDFz6Mfe.js → index-ClxHbCe9.js} +80 -102
- package/dist/prod/packages/shared-chunks/{on-B5NVufs_.js → on-CWgOWNSL.js} +6 -6
- package/dist/prod/packages/shared-chunks/{or-3AxY5TPj.js → or-Crsa2wci.js} +1 -1
- package/dist/prod/packages/shared-chunks/{setup-registry-C2KfZJWI.js → setup-registry-B3DhqtxX.js} +2 -2
- package/dist/prod/packages/shared-chunks/{textarea-CHqL0Rdh.js → textarea-Byj32raR.js} +6 -2
- package/docs/data.json +180 -180
- package/package.json +3 -6
- package/types/stable/@ember/-internals/glimmer/index.d.ts +165 -121
- package/types/stable/@ember/-internals/glimmer/lib/component.d.ts +8 -2
- package/types/stable/@ember/-internals/glimmer/lib/glimmer-tracking-docs.d.ts +12 -12
- package/types/stable/@ember/-internals/glimmer/lib/helper.d.ts +18 -6
- package/types/stable/@ember/-internals/glimmer/lib/helpers/array.d.ts +3 -1
- package/types/stable/@ember/-internals/glimmer/lib/helpers/component.d.ts +65 -121
- package/types/stable/@ember/-internals/glimmer/lib/helpers/concat.d.ts +8 -4
- package/types/stable/@ember/-internals/glimmer/lib/helpers/each-in.d.ts +16 -14
- package/types/stable/@ember/-internals/glimmer/lib/helpers/element.d.ts +2 -0
- package/types/stable/@ember/-internals/glimmer/lib/helpers/fn.d.ts +11 -7
- package/types/stable/@ember/-internals/glimmer/lib/helpers/get.d.ts +23 -29
- package/types/stable/@ember/-internals/glimmer/lib/helpers/hash.d.ts +3 -1
- package/types/stable/@ember/-internals/glimmer/lib/helpers/if-unless.d.ts +95 -49
- package/types/stable/@ember/-internals/glimmer/lib/helpers/mut.d.ts +23 -54
- package/types/stable/@ember/-internals/glimmer/lib/helpers/page-title.d.ts +6 -2
- package/types/stable/@ember/-internals/glimmer/lib/helpers/readonly.d.ts +4 -8
- package/types/stable/@ember/-internals/glimmer/lib/modifiers/on.d.ts +10 -10
- package/types/stable/@ember/-internals/glimmer/lib/syntax/in-element.d.ts +2 -0
- package/types/stable/@ember/-internals/glimmer/lib/syntax/let.d.ts +2 -14
- package/types/stable/@ember/-internals/glimmer/lib/syntax/mount.d.ts +15 -11
- package/types/stable/@ember/-internals/glimmer/lib/syntax/outlet.d.ts +17 -10
- package/types/stable/@ember/-internals/runtime/lib/mixins/target_action_support.d.ts +1 -1
- package/types/stable/@ember/array/index.d.ts +4 -0
- package/types/stable/@ember/controller/index.d.ts +1 -1
- package/types/stable/@ember/helper/index.d.ts +0 -19
- package/types/stable/@ember/object/index.d.ts +4 -3
- package/types/stable/@ember/object/observable.d.ts +4 -0
- package/types/stable/@ember/routing/route.d.ts +1 -1
- package/types/stable/@ember/routing/router-service.d.ts +20 -12
- package/types/stable/@glimmer/runtime/lib/helpers/array.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/helpers/concat.d.ts +8 -3
- package/types/stable/@glimmer/runtime/lib/helpers/fn.d.ts +13 -7
- package/types/stable/@glimmer/runtime/lib/helpers/get.d.ts +21 -29
- package/types/stable/@glimmer/runtime/lib/helpers/hash.d.ts +1 -1
- package/types/stable/@glimmer/syntax/lib/get-template-locals.d.ts +1 -1
- package/types/stable/@glimmer/tracking/index.d.ts +12 -12
|
@@ -17,26 +17,34 @@ declare module '@ember/-internals/glimmer/lib/helpers/if-unless' {
|
|
|
17
17
|
using the block form to wrap the section of template you want to conditionally render.
|
|
18
18
|
Like so:
|
|
19
19
|
|
|
20
|
-
```app/templates/application.
|
|
21
|
-
|
|
20
|
+
```app/templates/application.gjs
|
|
21
|
+
import Weather from '../components/weather';
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<Weather />
|
|
25
|
+
</template>
|
|
22
26
|
```
|
|
23
27
|
|
|
24
|
-
```app/components/weather.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
```app/components/weather.gjs
|
|
29
|
+
<template>
|
|
30
|
+
{{! will not render because greeting is undefined}}
|
|
31
|
+
{{#if @isRaining}}
|
|
32
|
+
Yes, grab an umbrella!
|
|
33
|
+
{{/if}}
|
|
34
|
+
</template>
|
|
29
35
|
```
|
|
30
36
|
|
|
31
37
|
You can also define what to show if the property is falsey by using
|
|
32
38
|
the `else` helper.
|
|
33
39
|
|
|
34
|
-
```app/components/weather.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
```app/components/weather.gjs
|
|
41
|
+
<template>
|
|
42
|
+
{{#if @isRaining}}
|
|
43
|
+
Yes, grab an umbrella!
|
|
44
|
+
{{else}}
|
|
45
|
+
No, it's lovely outside!
|
|
46
|
+
{{/if}}
|
|
47
|
+
</template>
|
|
40
48
|
```
|
|
41
49
|
|
|
42
50
|
You are also able to combine `else` and `if` helpers to create more complex
|
|
@@ -44,20 +52,26 @@ declare module '@ember/-internals/glimmer/lib/helpers/if-unless' {
|
|
|
44
52
|
|
|
45
53
|
For the following template:
|
|
46
54
|
|
|
47
|
-
```app/components/weather.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
```app/components/weather.gjs
|
|
56
|
+
<template>
|
|
57
|
+
{{#if @isRaining}}
|
|
58
|
+
Yes, grab an umbrella!
|
|
59
|
+
{{else if @isCold}}
|
|
60
|
+
Grab a coat, it's chilly!
|
|
61
|
+
{{else}}
|
|
62
|
+
No, it's lovely outside!
|
|
63
|
+
{{/if}}
|
|
64
|
+
</template>
|
|
55
65
|
```
|
|
56
66
|
|
|
57
67
|
If you call it by saying `isCold` is true:
|
|
58
68
|
|
|
59
|
-
```app/templates/application.
|
|
60
|
-
|
|
69
|
+
```app/templates/application.gjs
|
|
70
|
+
import Weather from '../components/weather';
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<Weather @isCold={{true}} />
|
|
74
|
+
</template>
|
|
61
75
|
```
|
|
62
76
|
|
|
63
77
|
Then `Grab a coat, it's chilly!` will be rendered.
|
|
@@ -71,12 +85,18 @@ declare module '@ember/-internals/glimmer/lib/helpers/if-unless' {
|
|
|
71
85
|
|
|
72
86
|
For example, if `useLongGreeting` is truthy, the following:
|
|
73
87
|
|
|
74
|
-
```app/templates/application.
|
|
75
|
-
|
|
88
|
+
```app/templates/application.gjs
|
|
89
|
+
import Greeting from '../components/greeting';
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<Greeting @useLongGreeting={{true}} />
|
|
93
|
+
<template>
|
|
76
94
|
```
|
|
77
95
|
|
|
78
|
-
```app/components/greeting.
|
|
79
|
-
|
|
96
|
+
```app/components/greeting.gjs
|
|
97
|
+
<template>
|
|
98
|
+
{{if @useLongGreeting "Hello" "Hi"}} Alex
|
|
99
|
+
<template>
|
|
80
100
|
```
|
|
81
101
|
|
|
82
102
|
Will render:
|
|
@@ -88,7 +108,9 @@ declare module '@ember/-internals/glimmer/lib/helpers/if-unless' {
|
|
|
88
108
|
One detail to keep in mind is that both branches of the `if` helper will be evaluated,
|
|
89
109
|
so if you have `{{if condition "foo" (expensive-operation "bar")`,
|
|
90
110
|
`expensive-operation` will always calculate.
|
|
91
|
-
|
|
111
|
+
|
|
112
|
+
`if` is built-in and does not need to be imported.
|
|
113
|
+
|
|
92
114
|
@method if
|
|
93
115
|
@for Ember.Templates.helpers
|
|
94
116
|
@public
|
|
@@ -107,12 +129,18 @@ declare module '@ember/-internals/glimmer/lib/helpers/if-unless' {
|
|
|
107
129
|
|
|
108
130
|
For example, if you pass a falsey `useLongGreeting` to the `Greeting` component:
|
|
109
131
|
|
|
110
|
-
```app/templates/application.
|
|
111
|
-
|
|
132
|
+
```app/templates/application.gjs
|
|
133
|
+
import Greeting from '../components/greeting';
|
|
134
|
+
|
|
135
|
+
<template>
|
|
136
|
+
<Greeting @useLongGreeting={{false}} />
|
|
137
|
+
</template>
|
|
112
138
|
```
|
|
113
139
|
|
|
114
|
-
```app/components/greeting.
|
|
115
|
-
|
|
140
|
+
```app/components/greeting.gjs
|
|
141
|
+
<template>
|
|
142
|
+
{{unless @useLongGreeting "Hi" "Hello"}} Ben
|
|
143
|
+
</template>
|
|
116
144
|
```
|
|
117
145
|
|
|
118
146
|
Then it will display:
|
|
@@ -127,14 +155,20 @@ declare module '@ember/-internals/glimmer/lib/helpers/if-unless' {
|
|
|
127
155
|
|
|
128
156
|
The following will not render anything:
|
|
129
157
|
|
|
130
|
-
```app/templates/application.
|
|
131
|
-
|
|
158
|
+
```app/templates/application.gjs
|
|
159
|
+
import Greeting from '../components/greeting';
|
|
160
|
+
|
|
161
|
+
<template>
|
|
162
|
+
<Greeting />
|
|
163
|
+
</template>
|
|
132
164
|
```
|
|
133
165
|
|
|
134
|
-
```app/components/greeting.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
166
|
+
```app/components/greeting.gjs
|
|
167
|
+
<template>
|
|
168
|
+
{{#unless @greeting}}
|
|
169
|
+
No greeting was found. Why not set one?
|
|
170
|
+
{{/unless}}
|
|
171
|
+
</template>
|
|
138
172
|
```
|
|
139
173
|
|
|
140
174
|
You can also use an `else` helper with the `unless` block. The
|
|
@@ -142,18 +176,24 @@ declare module '@ember/-internals/glimmer/lib/helpers/if-unless' {
|
|
|
142
176
|
|
|
143
177
|
If you have the following component:
|
|
144
178
|
|
|
145
|
-
```app/components/logged-in.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
179
|
+
```app/components/logged-in.gjs
|
|
180
|
+
<template>
|
|
181
|
+
{{#unless @userData}}
|
|
182
|
+
Please login.
|
|
183
|
+
{{else}}
|
|
184
|
+
Welcome back!
|
|
185
|
+
{{/unless}}
|
|
186
|
+
</template>
|
|
151
187
|
```
|
|
152
188
|
|
|
153
189
|
Calling it with a truthy `userData`:
|
|
154
190
|
|
|
155
|
-
```app/templates/application.
|
|
156
|
-
|
|
191
|
+
```app/templates/application.gjs
|
|
192
|
+
import LoggedIn from '../components/logged-in';
|
|
193
|
+
|
|
194
|
+
<template>
|
|
195
|
+
<LoggedIn @userData={{hash username="Zoey"}} />
|
|
196
|
+
</template>
|
|
157
197
|
```
|
|
158
198
|
|
|
159
199
|
Will render:
|
|
@@ -164,8 +204,12 @@ declare module '@ember/-internals/glimmer/lib/helpers/if-unless' {
|
|
|
164
204
|
|
|
165
205
|
and calling it with a falsey `userData`:
|
|
166
206
|
|
|
167
|
-
```app/templates/application.
|
|
168
|
-
|
|
207
|
+
```app/templates/application.gjs
|
|
208
|
+
import LoggedIn from '../components/logged-in';
|
|
209
|
+
|
|
210
|
+
<template>
|
|
211
|
+
<LoggedIn @userData={{false}} />
|
|
212
|
+
</template>
|
|
169
213
|
```
|
|
170
214
|
|
|
171
215
|
Will render:
|
|
@@ -173,7 +217,9 @@ declare module '@ember/-internals/glimmer/lib/helpers/if-unless' {
|
|
|
173
217
|
```html
|
|
174
218
|
Please login.
|
|
175
219
|
```
|
|
176
|
-
|
|
220
|
+
|
|
221
|
+
`unless` is built-in and does not need to be imported.
|
|
222
|
+
|
|
177
223
|
@method unless
|
|
178
224
|
@for Ember.Templates.helpers
|
|
179
225
|
@public
|
|
@@ -1,72 +1,41 @@
|
|
|
1
1
|
declare module '@ember/-internals/glimmer/lib/helpers/mut' {
|
|
2
2
|
/**
|
|
3
|
-
The `mut` helper
|
|
4
|
-
|
|
3
|
+
The `mut` helper is a shortcut for updating for args.
|
|
4
|
+
|
|
5
|
+
However, defining update functions on your backing class is preferable to using `mut`.
|
|
6
|
+
|
|
7
|
+
More directly: Don't use `mut`.
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<MyChild @childClickCount={{fn (mut totalClicks)}} />
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
or
|
|
13
|
-
|
|
14
|
-
```handlebars
|
|
15
|
-
{{my-child childClickCount=(mut totalClicks)}}
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
The child `Component` can then modify the parent's value just by modifying its own
|
|
19
|
-
property:
|
|
20
|
-
|
|
21
|
-
```javascript
|
|
22
|
-
// my-child.js
|
|
23
|
-
export default class MyChild extends Component {
|
|
24
|
-
click() {
|
|
25
|
-
this.incrementProperty('childClickCount');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Note that for curly components (`{{my-component}}`) the bindings are already mutable,
|
|
31
|
-
making the `mut` unnecessary.
|
|
32
|
-
|
|
33
|
-
Additionally, the `mut` helper can be combined with the `fn` helper to
|
|
34
|
-
mutate a value. For example:
|
|
35
|
-
|
|
36
|
-
```handlebars
|
|
37
|
-
<MyChild @childClickCount={{this.totalClicks}} @click-count-change={{fn (mut totalClicks))}} />
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
or
|
|
9
|
+
The `mut` helper, when used with `fn`, will return a function that
|
|
10
|
+
sets the value passed to `mut` to its first argument. As an example, we can create a
|
|
11
|
+
button that increments a value passing the value directly to the `fn`:
|
|
41
12
|
|
|
42
13
|
```handlebars
|
|
43
|
-
|
|
14
|
+
<MyChild @childClickCount={{this.totalClicks}} @clickCountChange={{fn (mut this.totalClicks)}} />
|
|
44
15
|
```
|
|
45
16
|
|
|
46
|
-
The child `Component` would invoke the function with the new click
|
|
17
|
+
The child `Component` would invoke the function with the new click count:
|
|
47
18
|
|
|
48
|
-
```
|
|
49
|
-
|
|
19
|
+
```app/components/my-child.gjs
|
|
20
|
+
import Component from '@glimmer/component';
|
|
21
|
+
import { action } from '@ember/object';
|
|
22
|
+
|
|
50
23
|
export default class MyChild extends Component {
|
|
51
|
-
|
|
52
|
-
|
|
24
|
+
@action
|
|
25
|
+
update() {
|
|
26
|
+
this.args.clickCountChange(this.args.childClickCount + 1);
|
|
53
27
|
}
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<button {{on "click" this.update}}>
|
|
31
|
+
Click me!
|
|
32
|
+
</button>
|
|
33
|
+
</template>
|
|
54
34
|
}
|
|
55
35
|
```
|
|
56
36
|
|
|
57
37
|
The `mut` helper changes the `totalClicks` value to what was provided as the `fn` argument.
|
|
58
38
|
|
|
59
|
-
The `mut` helper, when used with `fn`, will return a function that
|
|
60
|
-
sets the value passed to `mut` to its first argument. As an example, we can create a
|
|
61
|
-
button that increments a value passing the value directly to the `fn`:
|
|
62
|
-
|
|
63
|
-
```handlebars
|
|
64
|
-
{{! inc helper is not provided by Ember }}
|
|
65
|
-
<button onclick={{fn (mut count) (inc count)}}>
|
|
66
|
-
Increment count
|
|
67
|
-
</button>
|
|
68
|
-
```
|
|
69
|
-
|
|
70
39
|
@method mut
|
|
71
40
|
@param {Object} [attr] the "two-way" attribute that can be modified.
|
|
72
41
|
@for Ember.Templates.helpers
|
|
@@ -7,8 +7,12 @@ declare module '@ember/-internals/glimmer/lib/helpers/page-title' {
|
|
|
7
7
|
append additional titles for each route. For complete documentation, see
|
|
8
8
|
https://github.com/ember-cli/ember-page-title.
|
|
9
9
|
|
|
10
|
-
```
|
|
11
|
-
|
|
10
|
+
```gjs
|
|
11
|
+
import pageTitle from 'ember-page-title/helpers/page-title';
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
{{pageTitle "My Page Title" }}
|
|
15
|
+
</template>
|
|
12
16
|
```
|
|
13
17
|
|
|
14
18
|
@method page-title
|
|
@@ -2,6 +2,10 @@ declare module '@ember/-internals/glimmer/lib/helpers/readonly' {
|
|
|
2
2
|
/**
|
|
3
3
|
The `readonly` helper let's you specify that a binding is one-way only,
|
|
4
4
|
instead of two-way.
|
|
5
|
+
|
|
6
|
+
This is a vestigial helper from the days of `@ember/component` and does not apply to
|
|
7
|
+
components extending from `@glimmer/component`.
|
|
8
|
+
|
|
5
9
|
When you pass a `readonly` binding from an outer context (e.g. parent component),
|
|
6
10
|
to to an inner context (e.g. child component), you are saying that changing that
|
|
7
11
|
property in the inner context does not change the value in the outer context.
|
|
@@ -14,14 +18,6 @@ declare module '@ember/-internals/glimmer/lib/helpers/readonly' {
|
|
|
14
18
|
}
|
|
15
19
|
```
|
|
16
20
|
|
|
17
|
-
```app/templates/components/my-parent.hbs
|
|
18
|
-
{{log totalClicks}} // -> 3
|
|
19
|
-
<MyChild @childClickCount={{readonly totalClicks}} />
|
|
20
|
-
```
|
|
21
|
-
```
|
|
22
|
-
{{my-child childClickCount=(readonly totalClicks)}}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
21
|
Now, when you update `childClickCount`:
|
|
26
22
|
|
|
27
23
|
```app/components/my-child.js
|
|
@@ -10,20 +10,20 @@ declare module '@ember/-internals/glimmer/lib/modifiers/on' {
|
|
|
10
10
|
For example, if you'd like to run a function on your component when a `<button>`
|
|
11
11
|
in the components template is clicked you might do something like:
|
|
12
12
|
|
|
13
|
-
```app/components/like-post.
|
|
14
|
-
<button {{on 'click' this.saveLike}}>Like this post!</button>
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
```app/components/like-post.js
|
|
13
|
+
```app/components/like-post.gjs
|
|
18
14
|
import Component from '@glimmer/component';
|
|
19
15
|
import { action } from '@ember/object';
|
|
20
16
|
|
|
21
|
-
export default class
|
|
17
|
+
export default class LikePost extends Component {
|
|
22
18
|
@action
|
|
23
19
|
saveLike() {
|
|
24
20
|
// someone likes your post!
|
|
25
21
|
// better send a request off to your server...
|
|
26
22
|
}
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<button {{on 'click' this.saveLike}}>Like this post!</button>
|
|
26
|
+
</template>
|
|
27
27
|
}
|
|
28
28
|
```
|
|
29
29
|
|
|
@@ -58,7 +58,7 @@ declare module '@ember/-internals/glimmer/lib/modifiers/on' {
|
|
|
58
58
|
For example, in our example case above if you'd like to pass in the post that
|
|
59
59
|
was being liked when the button is clicked you could do something like:
|
|
60
60
|
|
|
61
|
-
```
|
|
61
|
+
```hbs
|
|
62
62
|
<button {{on 'click' (fn this.saveLike @post)}}>Like this post!</button>
|
|
63
63
|
```
|
|
64
64
|
|
|
@@ -68,13 +68,13 @@ declare module '@ember/-internals/glimmer/lib/modifiers/on' {
|
|
|
68
68
|
### Function Context
|
|
69
69
|
|
|
70
70
|
In the example above, we used `@action` to ensure that `likePost` is
|
|
71
|
-
properly bound to the `
|
|
71
|
+
properly bound to the `LikePost` Component, but let's explore what happens if we
|
|
72
72
|
left out `@action`:
|
|
73
73
|
|
|
74
|
-
```app/components/like-post.
|
|
74
|
+
```app/components/like-post.gjs
|
|
75
75
|
import Component from '@glimmer/component';
|
|
76
76
|
|
|
77
|
-
export default class
|
|
77
|
+
export default class LikePost extends Component {
|
|
78
78
|
saveLike() {
|
|
79
79
|
// ...snip...
|
|
80
80
|
}
|
|
@@ -32,21 +32,9 @@ declare module '@ember/-internals/glimmer/lib/syntax/let' {
|
|
|
32
32
|
<MyPost @title={{title}} @content={{content}} @options={{options}} />
|
|
33
33
|
{{/let}}
|
|
34
34
|
```
|
|
35
|
-
or
|
|
36
|
-
```handlebars
|
|
37
|
-
{{#let
|
|
38
|
-
(concat post.title ' | The Ember.js Blog')
|
|
39
|
-
post.content
|
|
40
|
-
(hash
|
|
41
|
-
theme="high-contrast"
|
|
42
|
-
enableComments=true
|
|
43
|
-
)
|
|
44
|
-
as |title content options|
|
|
45
|
-
}}
|
|
46
|
-
{{my-post title=title content=content options=options}}
|
|
47
|
-
{{/let}}
|
|
48
|
-
```
|
|
49
35
|
|
|
36
|
+
`let` is built-in and does not need to be imported.
|
|
37
|
+
|
|
50
38
|
@method let
|
|
51
39
|
@for Ember.Templates.helpers
|
|
52
40
|
@public
|
|
@@ -6,15 +6,14 @@ declare module '@ember/-internals/glimmer/lib/syntax/mount' {
|
|
|
6
6
|
|
|
7
7
|
For example, the following template mounts the `ember-chat` engine:
|
|
8
8
|
|
|
9
|
-
```
|
|
10
|
-
{{! application.hbs }}
|
|
9
|
+
```app/templates/application.gjs
|
|
11
10
|
{{mount "ember-chat"}}
|
|
12
11
|
```
|
|
13
12
|
|
|
14
13
|
Additionally, you can also pass in a `model` argument that will be
|
|
15
14
|
set as the engines model. This can be an existing object:
|
|
16
15
|
|
|
17
|
-
```
|
|
16
|
+
```hbs
|
|
18
17
|
<div>
|
|
19
18
|
{{mount 'admin' model=userSettings}}
|
|
20
19
|
</div>
|
|
@@ -22,15 +21,20 @@ declare module '@ember/-internals/glimmer/lib/syntax/mount' {
|
|
|
22
21
|
|
|
23
22
|
Or an inline `hash`, and you can even pass components:
|
|
24
23
|
|
|
24
|
+
```gjs
|
|
25
|
+
import SignInButton from '../components/sign-in-button';
|
|
26
|
+
<template>
|
|
27
|
+
<div>
|
|
28
|
+
<h1>Application template!</h1>
|
|
29
|
+
{{mount 'admin' model=(hash
|
|
30
|
+
title='Secret Admin'
|
|
31
|
+
signInButton=SignInButton
|
|
32
|
+
)}}
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
25
35
|
```
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{{mount 'admin' model=(hash
|
|
29
|
-
title='Secret Admin'
|
|
30
|
-
signInButton=(component 'sign-in-button')
|
|
31
|
-
)}}
|
|
32
|
-
</div>
|
|
33
|
-
```
|
|
36
|
+
|
|
37
|
+
`mount` is built-in and does not need to be imported.
|
|
34
38
|
|
|
35
39
|
@method mount
|
|
36
40
|
@param {String} name Name of the engine to mount.
|
|
@@ -2,23 +2,30 @@ declare module '@ember/-internals/glimmer/lib/syntax/outlet' {
|
|
|
2
2
|
/**
|
|
3
3
|
The `{{outlet}}` helper lets you specify where a child route will render in
|
|
4
4
|
your template. An important use of the `{{outlet}}` helper is in your
|
|
5
|
-
application's `application.
|
|
5
|
+
application's `application.gjs` file:
|
|
6
6
|
|
|
7
|
-
```app/templates/application.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
```app/templates/application.gjs
|
|
8
|
+
import MyHeader from '../components/my-header';
|
|
9
|
+
import MyFooter from '../components/my-footer';
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<MyHeader />
|
|
13
|
+
|
|
14
|
+
<div class="my-dynamic-content">
|
|
15
|
+
<!-- this content will change based on the current route, which depends on the current URL -->
|
|
16
|
+
{{outlet}}
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<MyFooter />
|
|
20
|
+
</template>
|
|
16
21
|
```
|
|
17
22
|
|
|
18
23
|
See the [routing guide](https://guides.emberjs.com/release/routing/rendering-a-template/) for more
|
|
19
24
|
information on how your `route` interacts with the `{{outlet}}` helper.
|
|
20
25
|
Note: Your content __will not render__ if there isn't an `{{outlet}}` for it.
|
|
21
26
|
|
|
27
|
+
`outlet` is built-in and does not need to be imported.
|
|
28
|
+
|
|
22
29
|
@method outlet
|
|
23
30
|
@for Ember.Templates.helpers
|
|
24
31
|
@public
|
|
@@ -5,7 +5,7 @@ declare module '@ember/-internals/runtime/lib/mixins/target_action_support' {
|
|
|
5
5
|
import Mixin from "@ember/object/mixin";
|
|
6
6
|
/**
|
|
7
7
|
`TargetActionSupport` is a mixin that can be included in a class
|
|
8
|
-
to add a `triggerAction` method with semantics similar to the
|
|
8
|
+
to add a `triggerAction` method with semantics similar to the
|
|
9
9
|
`{{action}}` helper. In normal Ember usage, the `{{action}}` helper is
|
|
10
10
|
usually the best choice. This mixin is most often useful when you are
|
|
11
11
|
doing more complex event handling in Components.
|
|
@@ -1274,6 +1274,10 @@ declare module '@ember/array' {
|
|
|
1274
1274
|
/**
|
|
1275
1275
|
Creates an `NativeArray` from an Array-like object.
|
|
1276
1276
|
Does not modify the original object's contents.
|
|
1277
|
+
|
|
1278
|
+
This exists primarily for historic reasons and should not be used
|
|
1279
|
+
in new code. Prefer native [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
|
1280
|
+
or [trackedArray](/ember/release/functions/@ember%2Freactive%2Fcollections/trackedArray).
|
|
1277
1281
|
|
|
1278
1282
|
Example
|
|
1279
1283
|
|
|
@@ -25,7 +25,7 @@ declare module '@ember/controller' {
|
|
|
25
25
|
/**
|
|
26
26
|
The object to which actions from the view should be sent.
|
|
27
27
|
|
|
28
|
-
For example, when a
|
|
28
|
+
For example, when a template uses the `{{action}}` helper,
|
|
29
29
|
it will attempt to send the action to the view's controller's `target`.
|
|
30
30
|
|
|
31
31
|
By default, the value of the target property is set to the router, and
|
|
@@ -322,18 +322,12 @@ declare module '@ember/helper' {
|
|
|
322
322
|
* as an argument to your components.
|
|
323
323
|
*
|
|
324
324
|
* ```
|
|
325
|
-
* import { hash } from '@ember/helper';
|
|
326
|
-
*
|
|
327
325
|
* <template>
|
|
328
326
|
* {{#each-in (hash givenName='Jen' familyName='Weber') as |key value|}}
|
|
329
327
|
* <p>{{key}}: {{value}}</p>
|
|
330
328
|
* {{/each-in}}
|
|
331
329
|
* </template>
|
|
332
330
|
* ```
|
|
333
|
-
*
|
|
334
|
-
* **NOTE:** this example uses the experimental `<template>` feature, which is
|
|
335
|
-
* the only place you need to import `hash` to use it (it is a built-in when
|
|
336
|
-
* writing standalone `.hbs` files).
|
|
337
331
|
*/
|
|
338
332
|
export const hash: HashHelper;
|
|
339
333
|
export interface HashHelper extends Opaque<"helper:hash"> {
|
|
@@ -343,7 +337,6 @@ declare module '@ember/helper' {
|
|
|
343
337
|
* as an argument to your components.
|
|
344
338
|
*
|
|
345
339
|
* ```js
|
|
346
|
-
* import { array } from '@ember/helper';
|
|
347
340
|
*
|
|
348
341
|
* <template>
|
|
349
342
|
* <ul>
|
|
@@ -352,10 +345,6 @@ declare module '@ember/helper' {
|
|
|
352
345
|
* {{/each}}
|
|
353
346
|
* </ul>
|
|
354
347
|
* </template>
|
|
355
|
-
*
|
|
356
|
-
* **NOTE:** this example uses the experimental `<template>` feature, which is
|
|
357
|
-
* the only place you need to import `array` to use it (it is a built-in when
|
|
358
|
-
* writing standalone `.hbs` files).
|
|
359
348
|
* ```
|
|
360
349
|
*/
|
|
361
350
|
export const array: ArrayHelper;
|
|
@@ -378,10 +367,6 @@ declare module '@ember/helper' {
|
|
|
378
367
|
*
|
|
379
368
|
* This will display the result of `@foo.item1` when `index` is `1`, and
|
|
380
369
|
* `this.foo.item2` when `index` is `2`, etc.
|
|
381
|
-
*
|
|
382
|
-
* **NOTE:** this example uses the experimental `<template>` feature, which is
|
|
383
|
-
* the only place you need to import `concat` to use it (it is a built-in when
|
|
384
|
-
* writing standalone `.hbs` files).
|
|
385
370
|
*/
|
|
386
371
|
export const concat: ConcatHelper;
|
|
387
372
|
export interface ConcatHelper extends Opaque<"helper:concat"> {
|
|
@@ -423,10 +408,6 @@ declare module '@ember/helper' {
|
|
|
423
408
|
*
|
|
424
409
|
* This will display the result of `@foo.item1` when `index` is `1`, and
|
|
425
410
|
* `this.foo.item2` when `index` is `2`, etc.
|
|
426
|
-
*
|
|
427
|
-
* **NOTE:** this example uses the experimental `<template>` feature, which is
|
|
428
|
-
* the only place you need to import `concat` to use it (it is a built-in when
|
|
429
|
-
* writing standalone `.hbs` files).
|
|
430
411
|
*/
|
|
431
412
|
export const get: GetHelper;
|
|
432
413
|
export interface GetHelper extends Opaque<"helper:get"> {
|
|
@@ -55,9 +55,10 @@ declare module '@ember/object' {
|
|
|
55
55
|
});
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
While observers are still supported, there are [plans to deprecate them](https://github.com/emberjs/rfcs/pull/1115)
|
|
59
|
+
See the [in-progress deprecation guide](https://github.com/ember-learn/deprecation-app/pull/1407)
|
|
60
|
+
for guidance on how to avoid using observers.
|
|
61
|
+
|
|
61
62
|
@method observer
|
|
62
63
|
@for @ember/object
|
|
63
64
|
@param {String} propertyNames*
|
|
@@ -307,6 +307,10 @@ declare module '@ember/object/observable' {
|
|
|
307
307
|
only a sender and key value as parameters or, if you aren't interested in
|
|
308
308
|
any of these values, to write an observer that has no parameters at all.
|
|
309
309
|
|
|
310
|
+
While observers are still supported, there are [plans to deprecate them](https://github.com/emberjs/rfcs/pull/1115)
|
|
311
|
+
See the [in-progress deprecation guide](https://github.com/ember-learn/deprecation-app/pull/1407)
|
|
312
|
+
for guidance on how to avoid using observers.
|
|
313
|
+
|
|
310
314
|
@method addObserver
|
|
311
315
|
@param {String} key The key to observe
|
|
312
316
|
@param {Object} target The target object to invoke
|
|
@@ -821,7 +821,7 @@ declare module '@ember/routing/route' {
|
|
|
821
821
|
|
|
822
822
|
Note that for routes with dynamic segments, this hook is not always
|
|
823
823
|
executed. If the route is entered through a transition (e.g. when
|
|
824
|
-
using the `link-to`
|
|
824
|
+
using the `link-to` helper or the `transitionTo` method
|
|
825
825
|
of routes), and a model context is already provided this hook
|
|
826
826
|
is not called.
|
|
827
827
|
|