ember-source 7.2.0-beta.1 → 7.2.1
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 +7 -7
- package/dist/dev/packages/@ember/-internals/routing/index.js +2 -2
- package/dist/dev/packages/@ember/-internals/runtime/index.js +1 -1
- package/dist/dev/packages/@ember/-internals/runtime/lib/ext/rsvp.js +1 -1
- package/dist/dev/packages/@ember/application/index.js +3 -3
- package/dist/dev/packages/@ember/application/instance.js +1 -1
- package/dist/dev/packages/@ember/component/helper.js +1 -1
- package/dist/dev/packages/@ember/component/index.js +3 -3
- package/dist/dev/packages/@ember/engine/index.js +3 -3
- package/dist/dev/packages/@ember/engine/instance.js +1 -1
- package/dist/dev/packages/@ember/helper/index.js +1132 -79
- package/dist/dev/packages/@ember/modifier/on.js +1 -1
- package/dist/dev/packages/@ember/object/compat.js +0 -32
- package/dist/dev/packages/@ember/renderer/index.js +1 -1
- package/dist/dev/packages/@ember/routing/-internals.js +2 -2
- package/dist/dev/packages/@ember/routing/index.js +6 -26
- package/dist/dev/packages/@ember/routing/lib/utils.js +2 -2
- package/dist/dev/packages/@ember/routing/route.js +2 -2
- package/dist/dev/packages/@ember/routing/router-service.js +9 -9
- package/dist/dev/packages/@ember/routing/router.js +2 -2
- package/dist/dev/packages/@ember/template-compiler/lib/compile-options.js +3 -3
- package/dist/dev/packages/@glimmer/runtime/index.js +7 -7
- package/dist/dev/packages/ember/version.js +1 -1
- package/dist/dev/packages/router_js/index.js +2 -2
- package/dist/dev/packages/rsvp/index.js +1 -2281
- package/dist/dev/packages/shared-chunks/{arguments-CDkbOqTS.js → arguments-BDcCvRM4.js} +5 -1
- package/dist/dev/packages/shared-chunks/{curly-Ei5G8jhk.js → curly-CxVJYzMX.js} +1 -1
- package/dist/dev/packages/shared-chunks/{element-BYLB-q7a.js → element-Cgoi4ldD.js} +0 -24
- package/dist/dev/packages/shared-chunks/get-BAZ7dSW_.js +40 -0
- package/dist/dev/packages/shared-chunks/hash-CKwikdMv.js +57 -0
- package/dist/dev/packages/shared-chunks/{helper-DIj85_-f.js → helper--ZiOCQkd.js} +2 -2
- package/dist/dev/packages/shared-chunks/{index-B3pPx1fL.js → index-CuorsWcn.js} +208 -84
- package/dist/dev/packages/shared-chunks/{invoke-d9sqa50M.js → invoke-DCF-tTDb.js} +1 -1
- package/dist/dev/packages/shared-chunks/{not-DYh6AY9Z.js → not-n3KAqx1U.js} +1 -1
- package/dist/dev/packages/shared-chunks/{on-DlF0Wy7P.js → on-CsI9Xgvl.js} +22 -11
- package/dist/dev/packages/shared-chunks/{render-87_sKZ_k.js → render-WPz2Nl45.js} +1 -1
- package/dist/{prod/packages/shared-chunks/rsvp.es-DR7yS7qg.js → dev/packages/shared-chunks/rsvp-aLN_pQtn.js} +152 -148
- package/dist/dev/packages/shared-chunks/{setup-registry-9DCmHTFF.js → setup-registry-5_gLCFs4.js} +3 -3
- package/dist/dev/packages/shared-chunks/{textarea-C4lYkaHj.js → textarea-B5TmhnQU.js} +2 -22
- package/dist/dev/packages/shared-chunks/{unique-id-DQOhouG1.js → unique-id-Csxuh1I7.js} +0 -4
- package/dist/dev/packages/shared-chunks/{unrecognized-url-error-BJHjL30Q.js → unrecognized-url-error-DyurFqvv.js} +1 -1
- package/dist/prod/packages/@ember/-internals/glimmer/index.js +7 -7
- package/dist/prod/packages/@ember/-internals/routing/index.js +2 -2
- package/dist/prod/packages/@ember/-internals/runtime/index.js +1 -1
- package/dist/prod/packages/@ember/-internals/runtime/lib/ext/rsvp.js +1 -1
- package/dist/prod/packages/@ember/application/index.js +3 -3
- package/dist/prod/packages/@ember/application/instance.js +1 -1
- package/dist/prod/packages/@ember/component/helper.js +1 -1
- package/dist/prod/packages/@ember/component/index.js +3 -3
- package/dist/prod/packages/@ember/engine/index.js +3 -3
- package/dist/prod/packages/@ember/engine/instance.js +1 -1
- package/dist/prod/packages/@ember/helper/index.js +1132 -79
- package/dist/prod/packages/@ember/modifier/on.js +1 -1
- package/dist/prod/packages/@ember/object/compat.js +0 -32
- package/dist/prod/packages/@ember/renderer/index.js +1 -1
- package/dist/prod/packages/@ember/routing/index.js +6 -26
- package/dist/prod/packages/@ember/routing/lib/utils.js +2 -2
- package/dist/prod/packages/@ember/routing/route.js +2 -2
- package/dist/prod/packages/@ember/routing/router-service.js +9 -9
- package/dist/prod/packages/@ember/routing/router.js +2 -2
- package/dist/prod/packages/@ember/template-compiler/lib/compile-options.js +3 -3
- package/dist/prod/packages/@glimmer/runtime/index.js +7 -7
- package/dist/prod/packages/ember/version.js +1 -1
- package/dist/prod/packages/router_js/index.js +2 -2
- package/dist/prod/packages/rsvp/index.js +1 -2281
- package/dist/prod/packages/shared-chunks/{arguments-BzAkZVBa.js → arguments-DxmU3uk4.js} +5 -1
- package/dist/prod/packages/shared-chunks/{curly-IY06zACp.js → curly-D2WsNyFi.js} +1 -1
- package/dist/prod/packages/shared-chunks/{element-DgHdPZ8u.js → element-BmBjPjkQ.js} +0 -24
- package/dist/prod/packages/shared-chunks/get-CMIqiKkx.js +40 -0
- package/dist/prod/packages/shared-chunks/hash-BPZcn79q.js +57 -0
- package/dist/prod/packages/shared-chunks/{helper-DkXiTBjc.js → helper-Df5MpdcT.js} +2 -2
- package/dist/prod/packages/shared-chunks/{index-CslMfEpb.js → index-DyYpsxuM.js} +208 -84
- package/dist/prod/packages/shared-chunks/{invoke-DhQ5QRp2.js → invoke-D7d52XJk.js} +1 -1
- package/dist/prod/packages/shared-chunks/{not-BOIVROuv.js → not-BGYHtDIW.js} +1 -1
- package/dist/prod/packages/shared-chunks/{on-BZHAxzdq.js → on-Ch0e_hqJ.js} +22 -11
- package/dist/prod/packages/shared-chunks/{render-Dx7lr1hR.js → render-CO2mZxto.js} +1 -1
- package/dist/{dev/packages/shared-chunks/rsvp.es-DR7yS7qg.js → prod/packages/shared-chunks/rsvp-aLN_pQtn.js} +152 -148
- package/dist/prod/packages/shared-chunks/{setup-registry-U-6VaNQG.js → setup-registry-jfUHS-vs.js} +3 -3
- package/dist/prod/packages/shared-chunks/{textarea-DOmZ1x0E.js → textarea-CQmTzSKe.js} +2 -22
- package/dist/prod/packages/shared-chunks/{unique-id-o2pS74go.js → unique-id-BJb1p8EG.js} +0 -4
- package/dist/prod/packages/shared-chunks/{unrecognized-url-error-EgNrnFu_.js → unrecognized-url-error-DgXBAzKl.js} +1 -1
- package/docs/data.json +1216 -1380
- package/package.json +3 -6
- package/types/stable/@ember/-internals/glimmer/index.d.ts +7 -380
- package/types/stable/@ember/-internals/glimmer/lib/component.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/helper.d.ts +2 -2
- package/types/stable/@ember/-internals/glimmer/lib/helpers/each-in.d.ts +171 -62
- package/types/stable/@ember/-internals/glimmer/lib/helpers/element.d.ts +0 -24
- package/types/stable/@ember/-internals/glimmer/lib/helpers/mut.d.ts +3 -2
- package/types/stable/@ember/-internals/glimmer/lib/helpers/readonly.d.ts +3 -1
- package/types/stable/@ember/-internals/glimmer/lib/helpers/unbound.d.ts +6 -2
- package/types/stable/@ember/-internals/glimmer/lib/helpers/unique-id.d.ts +0 -3
- package/types/stable/@ember/-internals/glimmer/lib/syntax/mount.d.ts +4 -2
- package/types/stable/@ember/-internals/glimmer/lib/syntax/outlet.d.ts +7 -2
- package/types/stable/@ember/helper/index.d.ts +1113 -73
- package/types/stable/@ember/object/compat.d.ts +0 -32
- package/types/stable/@ember/routing/router-service.d.ts +9 -9
- package/types/stable/@glimmer/runtime/lib/helpers/array.d.ts +0 -33
- package/types/stable/@glimmer/runtime/lib/helpers/concat.d.ts +0 -25
- package/types/stable/@glimmer/runtime/lib/helpers/fn.d.ts +0 -70
- package/types/stable/@glimmer/runtime/lib/helpers/get.d.ts +0 -69
- package/types/stable/@glimmer/runtime/lib/helpers/hash.d.ts +0 -36
- package/types/stable/index.d.ts +0 -14
- package/dist/dev/packages/shared-chunks/get-6I3sjd-I.js +0 -135
- package/dist/dev/packages/shared-chunks/hash-6NDs_5_f.js +0 -198
- package/dist/prod/packages/shared-chunks/get-Dago5uGl.js +0 -135
- package/dist/prod/packages/shared-chunks/hash-gEXIsSO4.js +0 -198
- package/types/stable/@ember/-internals/glimmer/lib/helpers/array.d.ts +0 -43
- package/types/stable/@ember/-internals/glimmer/lib/helpers/component.d.ts +0 -93
- package/types/stable/@ember/-internals/glimmer/lib/helpers/concat.d.ts +0 -32
- package/types/stable/@ember/-internals/glimmer/lib/helpers/fn.d.ts +0 -77
- package/types/stable/@ember/-internals/glimmer/lib/helpers/get.d.ts +0 -94
- package/types/stable/@ember/-internals/glimmer/lib/helpers/hash.d.ts +0 -46
- package/types/stable/@ember/-internals/glimmer/lib/helpers/helper.d.ts +0 -43
- package/types/stable/@ember/-internals/glimmer/lib/helpers/if-unless.d.ts +0 -228
- package/types/stable/@ember/-internals/glimmer/lib/helpers/log.d.ts +0 -19
- package/types/stable/@ember/-internals/glimmer/lib/helpers/modifier.d.ts +0 -42
- package/types/stable/@ember/-internals/glimmer/lib/helpers/page-title.d.ts +0 -24
- package/types/stable/@ember/-internals/glimmer/lib/modifiers/on.d.ts +0 -95
- package/types/stable/@ember/-internals/glimmer/lib/syntax/in-element.d.ts +0 -49
- package/types/stable/@ember/-internals/glimmer/lib/syntax/let.d.ts +0 -43
|
@@ -773,7 +773,11 @@ APPEND_OPCODES.add(VM_DYNAMIC_MODIFIER_OP, vm => {
|
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
775
|
if (!isConstRef(ref) || tag) {
|
|
776
|
-
|
|
776
|
+
let updateOpcode = new UpdateDynamicModifierOpcode(tag, instance, instanceRef);
|
|
777
|
+
|
|
778
|
+
// The block must own this opcode, or instances created on update are never destroyed.
|
|
779
|
+
vm.associateDestroyable(updateOpcode);
|
|
780
|
+
return vm.updateWith(updateOpcode);
|
|
777
781
|
}
|
|
778
782
|
});
|
|
779
783
|
class UpdateModifierOpcode {
|
|
@@ -3,7 +3,7 @@ import { g as guidFor } from './guid-Cbq2sNV_.js';
|
|
|
3
3
|
import { getViewElement, clearElementView, clearViewElement, addChildView, setViewElement, setElementView } from '../@ember/-internals/views/lib/system/utils.js';
|
|
4
4
|
import { _instrumentStart } from '../@ember/instrumentation/index.js';
|
|
5
5
|
import { c as createComputeRef, v as valueForRef, e as createPrimitiveRef, f as childRefFor, g as childRefFromParts, a as createConstRef, b as isUpdatableRef, u as updateRef } from './reference-CG0yPgLy.js';
|
|
6
|
-
import { f as reifyPositional } from './arguments-
|
|
6
|
+
import { f as reifyPositional } from './arguments-DxmU3uk4.js';
|
|
7
7
|
import { E as EMPTY_ARRAY } from './array-utils-CZQxrdD3.js';
|
|
8
8
|
import { a as valueForTag, p as beginUntrackFrame, w as endUntrackFrame, o as beginTrackFrame, s as endTrackFrame, c as consumeTag, v as validateTag } from './cache-CofLhaS4.js';
|
|
9
9
|
import { g as get } from './property_get-DAKgbeJX.js';
|
|
@@ -65,30 +65,6 @@ function getElementDefinition(tagName) {
|
|
|
65
65
|
|
|
66
66
|
// ============ Element Helper ============
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
The `element` helper lets you dynamically set the tag name of an element.
|
|
70
|
-
|
|
71
|
-
```handlebars
|
|
72
|
-
{{#let (element @tagName) as |Tag|}}
|
|
73
|
-
<Tag class="my-element">Hello</Tag>
|
|
74
|
-
{{/let}}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
When `@tagName` is `"h1"`, this renders `<h1 class="my-element">Hello</h1>`.
|
|
78
|
-
|
|
79
|
-
When `@tagName` is an empty string `""`, the block content is rendered without
|
|
80
|
-
a wrapping element.
|
|
81
|
-
|
|
82
|
-
Passing `null`, `undefined`, or non-string values will throw an assertion error.
|
|
83
|
-
|
|
84
|
-
Changing the tag name will tear down and recreate the element and its contents.
|
|
85
|
-
|
|
86
|
-
The `element` helper is built-in and does not need to be imported.
|
|
87
|
-
|
|
88
|
-
@method element
|
|
89
|
-
@for Ember.Templates.helpers
|
|
90
|
-
@public
|
|
91
|
-
*/
|
|
92
68
|
const element = internalHelper(({
|
|
93
69
|
positional,
|
|
94
70
|
named
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { c as createComputeRef, U as UNDEFINED_REFERENCE, v as valueForRef } from './reference-CG0yPgLy.js';
|
|
2
|
+
import { f as reifyPositional } from './arguments-DxmU3uk4.js';
|
|
3
|
+
import { i as internalHelper } from './hash-BPZcn79q.js';
|
|
4
|
+
import { setPath, getPath } from '../@glimmer/global-context/index.js';
|
|
5
|
+
import { i as isDict } from './collections-GpG8lT2g.js';
|
|
6
|
+
|
|
7
|
+
const isEmpty = value => {
|
|
8
|
+
return value === null || value === undefined || typeof value.toString !== 'function';
|
|
9
|
+
};
|
|
10
|
+
const normalizeTextValue = value => {
|
|
11
|
+
if (isEmpty(value)) {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
return String(value);
|
|
15
|
+
};
|
|
16
|
+
const concat = internalHelper(({
|
|
17
|
+
positional
|
|
18
|
+
}) => {
|
|
19
|
+
return createComputeRef(() => reifyPositional(positional).map(normalizeTextValue).join(''), null, 'concat');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const get = internalHelper(({
|
|
23
|
+
positional
|
|
24
|
+
}) => {
|
|
25
|
+
let sourceRef = positional[0] ?? UNDEFINED_REFERENCE;
|
|
26
|
+
let pathRef = positional[1] ?? UNDEFINED_REFERENCE;
|
|
27
|
+
return createComputeRef(() => {
|
|
28
|
+
let source = valueForRef(sourceRef);
|
|
29
|
+
if (isDict(source)) {
|
|
30
|
+
return getPath(source, String(valueForRef(pathRef)));
|
|
31
|
+
}
|
|
32
|
+
}, value => {
|
|
33
|
+
let source = valueForRef(sourceRef);
|
|
34
|
+
if (isDict(source)) {
|
|
35
|
+
return setPath(source, String(valueForRef(pathRef)), value);
|
|
36
|
+
}
|
|
37
|
+
}, 'get');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export { concat as c, get as g };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { c as createComputeRef, d as isInvokableRef, u as updateRef } from './reference-CG0yPgLy.js';
|
|
2
|
+
import { f as reifyPositional, g as check, e as reifyNamed } from './arguments-DxmU3uk4.js';
|
|
3
|
+
import { j as setInternalHelperManager } from './api-DlJKfm_f.js';
|
|
4
|
+
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
6
|
+
function buildUntouchableThis(source) {
|
|
7
|
+
let context = null;
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function internalHelper(helper) {
|
|
12
|
+
return setInternalHelperManager(helper, {});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const array = internalHelper(({
|
|
16
|
+
positional
|
|
17
|
+
}) => {
|
|
18
|
+
return createComputeRef(() => reifyPositional(positional), null, 'array');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const context = buildUntouchableThis();
|
|
22
|
+
const fn = internalHelper(({
|
|
23
|
+
positional
|
|
24
|
+
}) => {
|
|
25
|
+
let callbackRef = check(positional[0]);
|
|
26
|
+
return createComputeRef(() => {
|
|
27
|
+
return (...invocationArgs) => {
|
|
28
|
+
let [fn, ...args] = reifyPositional(positional);
|
|
29
|
+
if (isInvokableRef(callbackRef)) {
|
|
30
|
+
let value = args.length > 0 ? args[0] : invocationArgs[0];
|
|
31
|
+
return void updateRef(callbackRef, value);
|
|
32
|
+
} else {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return -- @fixme
|
|
34
|
+
return fn.call(context, ...args, ...invocationArgs);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}, null, 'fn');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const hash = internalHelper(({
|
|
41
|
+
named
|
|
42
|
+
}) => {
|
|
43
|
+
let ref = createComputeRef(() => {
|
|
44
|
+
return reifyNamed(named);
|
|
45
|
+
}, null, 'hash');
|
|
46
|
+
|
|
47
|
+
// Setup the children so that templates can bypass getting the value of
|
|
48
|
+
// the reference and treat children lazily
|
|
49
|
+
let children = new Map();
|
|
50
|
+
for (let name in named) {
|
|
51
|
+
children.set(name, named[name]);
|
|
52
|
+
}
|
|
53
|
+
ref.children = children;
|
|
54
|
+
return ref;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export { array as a, fn as f, hash as h, internalHelper as i };
|
|
@@ -27,7 +27,7 @@ const IS_CLASSIC_HELPER = Symbol('IS_CLASSIC_HELPER');
|
|
|
27
27
|
Ember Helpers are functions that can compute values, and are used in templates.
|
|
28
28
|
For example, this code calls a helper named `format-currency`:
|
|
29
29
|
|
|
30
|
-
```app/templates/application.gjs
|
|
30
|
+
```gjs {data-filename="app/templates/application.gjs"}
|
|
31
31
|
import Cost from '../components/cost';
|
|
32
32
|
|
|
33
33
|
<template>
|
|
@@ -35,7 +35,7 @@ const IS_CLASSIC_HELPER = Symbol('IS_CLASSIC_HELPER');
|
|
|
35
35
|
</template>
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
```app/components/cost.gjs
|
|
38
|
+
```gjs {data-filename="app/components/cost.gjs"}
|
|
39
39
|
import formatCurrency from '../helpers/format-currency';
|
|
40
40
|
|
|
41
41
|
<template>
|
|
@@ -11,10 +11,10 @@ import { artifacts } from '../@glimmer/program/index.js';
|
|
|
11
11
|
import { R as RuntimeOpImpl } from './program-BAh__OXZ.js';
|
|
12
12
|
import { v as valueForRef, U as UNDEFINED_REFERENCE, c as createComputeRef, a as createConstRef, h as createInvokableRef, j as createReadOnlyRef, k as createUnboundRef, g as childRefFromParts, u as updateRef } from './reference-CG0yPgLy.js';
|
|
13
13
|
import { c as clientBuilder } from './api-CQexacBn.js';
|
|
14
|
-
import { E as EMPTY_ARGS, c as createCapturedArgs, b as EMPTY_POSITIONAL, d as curry } from './arguments-
|
|
15
|
-
import { g as runtimeOptions, i as inTransaction, r as renderComponent$1, d as renderMain } from './render-
|
|
14
|
+
import { E as EMPTY_ARGS, c as createCapturedArgs, b as EMPTY_POSITIONAL, d as curry } from './arguments-DxmU3uk4.js';
|
|
15
|
+
import { g as runtimeOptions, i as inTransaction, r as renderComponent$1, d as renderMain } from './render-CO2mZxto.js';
|
|
16
16
|
import { d as dict } from './collections-GpG8lT2g.js';
|
|
17
|
-
import { u as unwrapTemplate, a as CurlyComponentManager, i as initialRenderInstrumentDetails, b as ComponentStateBucket, D as DIRTY_TAG, c as isCurlyManager, B as BOUNDS } from './curly-
|
|
17
|
+
import { u as unwrapTemplate, a as CurlyComponentManager, i as initialRenderInstrumentDetails, b as ComponentStateBucket, D as DIRTY_TAG, c as isCurlyManager, B as BOUNDS } from './curly-D2WsNyFi.js';
|
|
18
18
|
import { C as CONSTANT_TAG, c as consumeTag, f as isTracking, D as DIRTY_TAG$1, r as createTag, a as valueForTag, k as CURRENT_TAG, v as validateTag } from './cache-CofLhaS4.js';
|
|
19
19
|
import { _instrumentStart } from '../@ember/instrumentation/index.js';
|
|
20
20
|
import { c as capabilityFlagsFrom } from './capabilities-BuVYh-vx.js';
|
|
@@ -34,13 +34,13 @@ import { i as isHTMLSafe } from './index-D-xTBV4B.js';
|
|
|
34
34
|
import isArray from '../@ember/array/lib/is-array.js';
|
|
35
35
|
import { g as getComponentTemplate } from './template-Dc_cBOoX.js';
|
|
36
36
|
import { c as hasInternalComponentManager, j as setInternalHelperManager, g as getInternalComponentManager } from './api-DlJKfm_f.js';
|
|
37
|
-
import { h as hash, f as fn, a as array } from './hash-
|
|
38
|
-
import { g as get$1, c as concat } from './get-
|
|
39
|
-
import { o as on } from './on-
|
|
37
|
+
import { h as hash, f as fn, a as array } from './hash-BPZcn79q.js';
|
|
38
|
+
import { g as get$1, c as concat } from './get-CMIqiKkx.js';
|
|
39
|
+
import { o as on } from './on-Ch0e_hqJ.js';
|
|
40
40
|
import { T as TEMPLATE_ONLY_COMPONENT_MANAGER, t as templateOnlyComponent } from './template-only-DKNcKM5b.js';
|
|
41
|
-
import { i as isClassicHelper, C as CLASSIC_HELPER_MANAGER } from './helper-
|
|
41
|
+
import { i as isClassicHelper, C as CLASSIC_HELPER_MANAGER } from './helper-Df5MpdcT.js';
|
|
42
42
|
import { dasherize } from '../@ember/-internals/string/index.js';
|
|
43
|
-
import { a as uniqueId } from './unique-id-
|
|
43
|
+
import { a as uniqueId } from './unique-id-BJb1p8EG.js';
|
|
44
44
|
import { generateControllerFactory } from '../@ember/routing/lib/generate_controller.js';
|
|
45
45
|
import { E as EvaluationContextImpl } from './program-context-COSioH46.js';
|
|
46
46
|
|
|
@@ -231,7 +231,7 @@ class RootComponentDefinition {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
/**
|
|
234
|
-
@module ember
|
|
234
|
+
@module @ember/helper
|
|
235
235
|
*/
|
|
236
236
|
|
|
237
237
|
/**
|
|
@@ -241,46 +241,91 @@ class RootComponentDefinition {
|
|
|
241
241
|
The default behavior of `{{#each}}` is to yield its inner block once for every
|
|
242
242
|
item in an array passing the item as the first block parameter.
|
|
243
243
|
|
|
244
|
-
|
|
244
|
+
```gjs {data-filename="app/components/developer-list.gjs"}
|
|
245
|
+
import Component from '@glimmer/component';
|
|
245
246
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
247
|
+
export default class DeveloperList extends Component {
|
|
248
|
+
developers = [
|
|
249
|
+
{ name: 'Yehuda' },
|
|
250
|
+
{ name: 'Tom' },
|
|
251
|
+
{ name: 'Paul' },
|
|
252
|
+
];
|
|
249
253
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
<template>
|
|
255
|
+
<ul>
|
|
256
|
+
{{#each this.developers as |person|}}
|
|
257
|
+
<li>Hello, {{person.name}}!</li>
|
|
258
|
+
{{/each}}
|
|
259
|
+
</ul>
|
|
260
|
+
</template>
|
|
261
|
+
}
|
|
256
262
|
```
|
|
257
263
|
|
|
258
|
-
The same rules apply to arrays of primitives
|
|
264
|
+
The same rules apply to arrays of primitives:
|
|
265
|
+
|
|
266
|
+
```app/components/developer-names.gjs
|
|
267
|
+
import Component from '@glimmer/component';
|
|
268
|
+
|
|
269
|
+
export default class DeveloperNames extends Component {
|
|
270
|
+
developerNames = ['Yehuda', 'Tom', 'Paul'];
|
|
259
271
|
|
|
260
|
-
|
|
261
|
-
|
|
272
|
+
<template>
|
|
273
|
+
<ul>
|
|
274
|
+
{{#each this.developerNames as |name|}}
|
|
275
|
+
<li>Hello, {{name}}!</li>
|
|
276
|
+
{{/each}}
|
|
277
|
+
</ul>
|
|
278
|
+
</template>
|
|
279
|
+
}
|
|
262
280
|
```
|
|
263
281
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
282
|
+
`{{#each}}` also supports native JavaScript [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
|
|
283
|
+
values and other iterables:
|
|
284
|
+
|
|
285
|
+
```gjs {data-filename="app/components/developer-set.gjs"}
|
|
286
|
+
import Component from '@glimmer/component';
|
|
287
|
+
|
|
288
|
+
export default class DeveloperSet extends Component {
|
|
289
|
+
developers = new Set([
|
|
290
|
+
{ name: 'Yehuda' },
|
|
291
|
+
{ name: 'Tom' },
|
|
292
|
+
{ name: 'Paul' },
|
|
293
|
+
]);
|
|
294
|
+
|
|
295
|
+
<template>
|
|
296
|
+
<ul>
|
|
297
|
+
{{#each this.developers as |person|}}
|
|
298
|
+
<li>Hello, {{person.name}}!</li>
|
|
299
|
+
{{/each}}
|
|
300
|
+
</ul>
|
|
301
|
+
</template>
|
|
302
|
+
}
|
|
270
303
|
```
|
|
271
304
|
|
|
272
|
-
During iteration, the index of each item in the array is provided as a second
|
|
273
|
-
parameter
|
|
305
|
+
During iteration, the index of each item in the array is provided as a second
|
|
306
|
+
block parameter:
|
|
274
307
|
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
308
|
+
```app/components/developer-list-with-index.gjs
|
|
309
|
+
import Component from '@glimmer/component';
|
|
310
|
+
|
|
311
|
+
export default class DeveloperListWithIndex extends Component {
|
|
312
|
+
developers = [
|
|
313
|
+
{ name: 'Yehuda' },
|
|
314
|
+
{ name: 'Tom' },
|
|
315
|
+
{ name: 'Paul' },
|
|
316
|
+
];
|
|
317
|
+
|
|
318
|
+
<template>
|
|
319
|
+
<ul>
|
|
320
|
+
{{#each this.developers as |person index|}}
|
|
321
|
+
<li>Hello, {{person.name}}! You're number {{index}} in line</li>
|
|
322
|
+
{{/each}}
|
|
323
|
+
</ul>
|
|
324
|
+
</template>
|
|
325
|
+
}
|
|
281
326
|
```
|
|
282
|
-
|
|
283
|
-
`#each` is a keyword and does not need to be imported.
|
|
327
|
+
|
|
328
|
+
`#each` is a keyword and does not need to be imported.
|
|
284
329
|
|
|
285
330
|
### Specifying Keys
|
|
286
331
|
|
|
@@ -296,30 +341,38 @@ class RootComponentDefinition {
|
|
|
296
341
|
needed. However, in some rare cases, the objects' identities may change even
|
|
297
342
|
though they represent the same underlying data.
|
|
298
343
|
|
|
299
|
-
For example
|
|
344
|
+
For example, mapping over `people` produces a new array of new objects on each
|
|
345
|
+
render. Use `key` so Ember can match items across those renders:
|
|
300
346
|
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
return { ...person, type: 'developer' };
|
|
304
|
-
});
|
|
305
|
-
```
|
|
347
|
+
```gjs {data-filename="app/components/mapped-developers.gjs"}
|
|
348
|
+
import Component from '@glimmer/component';
|
|
306
349
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
350
|
+
export default class MappedDevelopers extends Component {
|
|
351
|
+
people = [
|
|
352
|
+
{ name: 'Yehuda' },
|
|
353
|
+
{ name: 'Tom' },
|
|
354
|
+
{ name: 'Paul' },
|
|
355
|
+
];
|
|
311
356
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
357
|
+
get developers() {
|
|
358
|
+
return this.people.map((person) => {
|
|
359
|
+
return { ...person, type: 'developer' };
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
<template>
|
|
364
|
+
<ul>
|
|
365
|
+
{{#each this.developers key="name" as |person|}}
|
|
366
|
+
<li>Hello, {{person.name}}!</li>
|
|
367
|
+
{{/each}}
|
|
368
|
+
</ul>
|
|
369
|
+
</template>
|
|
370
|
+
}
|
|
318
371
|
```
|
|
319
372
|
|
|
320
373
|
By doing so, Ember will use the value of the property specified (`person.name`
|
|
321
374
|
in the example) to find a "match" from the previous render. That is, if Ember
|
|
322
|
-
has previously seen an object from the
|
|
375
|
+
has previously seen an object from the `developers` array with a matching
|
|
323
376
|
name, its DOM elements will be re-used.
|
|
324
377
|
|
|
325
378
|
There are two special values for `key`:
|
|
@@ -332,36 +385,47 @@ class RootComponentDefinition {
|
|
|
332
385
|
`{{#each}}` can have a matching `{{else}}`. The contents of this block will render
|
|
333
386
|
if the collection is empty.
|
|
334
387
|
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
388
|
+
```gjs {data-filename="app/components/available-developers.gjs"}
|
|
389
|
+
import Component from '@glimmer/component';
|
|
390
|
+
|
|
391
|
+
export default class AvailableDevelopers extends Component {
|
|
392
|
+
developers = [];
|
|
393
|
+
|
|
394
|
+
<template>
|
|
395
|
+
<ul>
|
|
396
|
+
{{#each this.developers as |person|}}
|
|
397
|
+
<li>{{person.name}} is available!</li>
|
|
398
|
+
{{else}}
|
|
399
|
+
<li>Sorry, nobody is available for this task.</li>
|
|
400
|
+
{{/each}}
|
|
401
|
+
</ul>
|
|
402
|
+
</template>
|
|
403
|
+
}
|
|
343
404
|
```
|
|
344
405
|
|
|
345
406
|
@method each
|
|
346
|
-
@for
|
|
407
|
+
@for Keywords
|
|
408
|
+
@static
|
|
409
|
+
@noimport
|
|
347
410
|
@public
|
|
348
411
|
*/
|
|
349
412
|
|
|
350
413
|
/**
|
|
351
|
-
The `{{#each-in}}` keyword loops over properties on an object
|
|
414
|
+
The `{{#each-in}}` keyword loops over properties on an object, or entries in a
|
|
415
|
+
native JavaScript [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map).
|
|
352
416
|
|
|
353
417
|
For example, given this component definition:
|
|
354
418
|
|
|
355
|
-
```app/components/developer-details.gjs
|
|
419
|
+
```gjs {data-filename="app/components/developer-details.gjs"}
|
|
356
420
|
import Component from '@glimmer/component';
|
|
357
421
|
import { tracked } from '@glimmer/tracking';
|
|
358
422
|
|
|
359
|
-
export default class extends Component {
|
|
423
|
+
export default class DeveloperDetails extends Component {
|
|
360
424
|
@tracked developer = {
|
|
361
|
-
|
|
362
|
-
|
|
425
|
+
name: 'Shelly Sails',
|
|
426
|
+
age: 42,
|
|
363
427
|
};
|
|
364
|
-
|
|
428
|
+
|
|
365
429
|
<template>
|
|
366
430
|
<ul>
|
|
367
431
|
{{#each-in this.developer as |key value|}}
|
|
@@ -381,11 +445,56 @@ class RootComponentDefinition {
|
|
|
381
445
|
<li>age: 42</li>
|
|
382
446
|
</ul>
|
|
383
447
|
```
|
|
384
|
-
|
|
448
|
+
|
|
449
|
+
The same pattern works with a `Map`:
|
|
450
|
+
|
|
451
|
+
```gjs {data-filename="app/components/developer-map.gjs"}
|
|
452
|
+
import Component from '@glimmer/component';
|
|
453
|
+
|
|
454
|
+
export default class DeveloperMap extends Component {
|
|
455
|
+
map = new Map([
|
|
456
|
+
['name', 'Shelly Sails'],
|
|
457
|
+
['age', 42],
|
|
458
|
+
]);
|
|
459
|
+
|
|
460
|
+
<template>
|
|
461
|
+
<ul>
|
|
462
|
+
{{#each-in this.map as |key value|}}
|
|
463
|
+
<li>{{key}}: {{value}}</li>
|
|
464
|
+
{{/each-in}}
|
|
465
|
+
</ul>
|
|
466
|
+
</template>
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
When a `Map` uses object keys, you can pass `key="@identity"` to explicitly
|
|
471
|
+
track entries across re-renders using the JavaScript identity of each key:
|
|
472
|
+
|
|
473
|
+
```gjs {data-filename="app/components/object-keyed-map.gjs"}
|
|
474
|
+
import Component from '@glimmer/component';
|
|
475
|
+
|
|
476
|
+
export default class ObjectKeyedMap extends Component {
|
|
477
|
+
map = new Map([
|
|
478
|
+
[{ name: 'one' }, 'foo'],
|
|
479
|
+
[{ name: 'two' }, 'bar'],
|
|
480
|
+
]);
|
|
481
|
+
|
|
482
|
+
<template>
|
|
483
|
+
<ul>
|
|
484
|
+
{{#each-in this.map key="@identity" as |key value|}}
|
|
485
|
+
<li>{{key.name}}: {{value}}</li>
|
|
486
|
+
{{/each-in}}
|
|
487
|
+
</ul>
|
|
488
|
+
</template>
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
385
492
|
`#each-in` is a keyword and does not need to be imported.
|
|
386
493
|
|
|
387
494
|
@method each-in
|
|
388
|
-
@
|
|
495
|
+
@static
|
|
496
|
+
@noimport
|
|
497
|
+
@for Keywords
|
|
389
498
|
@public
|
|
390
499
|
@since 2.1.0
|
|
391
500
|
*/
|
|
@@ -770,7 +879,7 @@ const trackArray = internalHelper(({
|
|
|
770
879
|
});
|
|
771
880
|
|
|
772
881
|
/**
|
|
773
|
-
@module ember
|
|
882
|
+
@module @ember/helper
|
|
774
883
|
*/
|
|
775
884
|
|
|
776
885
|
/**
|
|
@@ -790,7 +899,7 @@ const trackArray = internalHelper(({
|
|
|
790
899
|
|
|
791
900
|
The child `Component` would invoke the function with the new click count:
|
|
792
901
|
|
|
793
|
-
```app/components/my-child.gjs
|
|
902
|
+
```gjs {data-filename="app/components/my-child.gjs"}
|
|
794
903
|
import Component from '@glimmer/component';
|
|
795
904
|
import { action } from '@ember/object';
|
|
796
905
|
|
|
@@ -812,7 +921,8 @@ const trackArray = internalHelper(({
|
|
|
812
921
|
|
|
813
922
|
@method mut
|
|
814
923
|
@param {Object} [attr] the "two-way" attribute that can be modified.
|
|
815
|
-
@
|
|
924
|
+
@static
|
|
925
|
+
@for Keywords
|
|
816
926
|
@public
|
|
817
927
|
*/
|
|
818
928
|
|
|
@@ -824,7 +934,7 @@ const mut = internalHelper(({
|
|
|
824
934
|
});
|
|
825
935
|
|
|
826
936
|
/**
|
|
827
|
-
@module ember
|
|
937
|
+
@module @ember/helper
|
|
828
938
|
*/
|
|
829
939
|
|
|
830
940
|
|
|
@@ -936,7 +1046,9 @@ const mut = internalHelper(({
|
|
|
936
1046
|
|
|
937
1047
|
@method readonly
|
|
938
1048
|
@param {Object} [attr] the read-only attribute.
|
|
939
|
-
@for
|
|
1049
|
+
@for Keywords
|
|
1050
|
+
@noimport
|
|
1051
|
+
@static
|
|
940
1052
|
@private
|
|
941
1053
|
*/
|
|
942
1054
|
const readonly = internalHelper(({
|
|
@@ -947,7 +1059,7 @@ const readonly = internalHelper(({
|
|
|
947
1059
|
});
|
|
948
1060
|
|
|
949
1061
|
/**
|
|
950
|
-
@module ember
|
|
1062
|
+
@module @ember/helper
|
|
951
1063
|
*/
|
|
952
1064
|
|
|
953
1065
|
|
|
@@ -973,9 +1085,13 @@ const readonly = internalHelper(({
|
|
|
973
1085
|
|
|
974
1086
|
The `unbound` helper only accepts a single argument, and it return an
|
|
975
1087
|
unbound value.
|
|
1088
|
+
|
|
1089
|
+
`unbound` is a template keyword and does not need to be imported.
|
|
976
1090
|
|
|
977
1091
|
@method unbound
|
|
978
|
-
@
|
|
1092
|
+
@static
|
|
1093
|
+
@noimport
|
|
1094
|
+
@for Keywords
|
|
979
1095
|
@public
|
|
980
1096
|
*/
|
|
981
1097
|
|
|
@@ -1112,7 +1228,7 @@ class MountDefinition {
|
|
|
1112
1228
|
}
|
|
1113
1229
|
|
|
1114
1230
|
/**
|
|
1115
|
-
@module ember
|
|
1231
|
+
@module @ember/helper
|
|
1116
1232
|
*/
|
|
1117
1233
|
|
|
1118
1234
|
|
|
@@ -1123,7 +1239,7 @@ class MountDefinition {
|
|
|
1123
1239
|
|
|
1124
1240
|
For example, the following template mounts the `ember-chat` engine:
|
|
1125
1241
|
|
|
1126
|
-
```app/templates/application.gjs
|
|
1242
|
+
```gjs {data-filename="app/templates/application.gjs"}
|
|
1127
1243
|
{{mount "ember-chat"}}
|
|
1128
1244
|
```
|
|
1129
1245
|
|
|
@@ -1157,7 +1273,9 @@ class MountDefinition {
|
|
|
1157
1273
|
@param {String} name Name of the engine to mount.
|
|
1158
1274
|
@param {Object} [model] Object that will be set as
|
|
1159
1275
|
the model of the engine.
|
|
1160
|
-
@for
|
|
1276
|
+
@for Keywords
|
|
1277
|
+
@static
|
|
1278
|
+
@noimport
|
|
1161
1279
|
@public
|
|
1162
1280
|
*/
|
|
1163
1281
|
const mountHelper = internalHelper((args, owner) => {
|
|
@@ -1280,12 +1398,16 @@ function makeRouteTemplate(owner, name, template) {
|
|
|
1280
1398
|
return curry(0, routeTemplate, owner, null, true);
|
|
1281
1399
|
}
|
|
1282
1400
|
|
|
1401
|
+
/**
|
|
1402
|
+
@module @ember/helper
|
|
1403
|
+
*/
|
|
1404
|
+
|
|
1283
1405
|
/**
|
|
1284
1406
|
The `{{outlet}}` helper lets you specify where a child route will render in
|
|
1285
1407
|
your template. An important use of the `{{outlet}}` helper is in your
|
|
1286
1408
|
application's `application.gjs` file:
|
|
1287
1409
|
|
|
1288
|
-
```app/templates/application.gjs
|
|
1410
|
+
```gjs {data-filename="app/templates/application.gjs"}
|
|
1289
1411
|
import MyHeader from '../components/my-header';
|
|
1290
1412
|
import MyFooter from '../components/my-footer';
|
|
1291
1413
|
|
|
@@ -1308,7 +1430,9 @@ function makeRouteTemplate(owner, name, template) {
|
|
|
1308
1430
|
`outlet` is built-in and does not need to be imported.
|
|
1309
1431
|
|
|
1310
1432
|
@method outlet
|
|
1311
|
-
@for
|
|
1433
|
+
@for Keywords
|
|
1434
|
+
@static
|
|
1435
|
+
@noimport
|
|
1312
1436
|
@public
|
|
1313
1437
|
*/
|
|
1314
1438
|
const outletHelper = internalHelper((_args, owner, scope) => {
|
|
@@ -2,7 +2,7 @@ import { associateDestroyableChild } from '../@glimmer/destroyable/index.js';
|
|
|
2
2
|
import { a as getInternalHelperManager, f as hasValue, h as hasDestroyable } from './api-DlJKfm_f.js';
|
|
3
3
|
import { getOwner } from '../@glimmer/owner/index.js';
|
|
4
4
|
import { e as createCache, g as getValue } from './cache-CofLhaS4.js';
|
|
5
|
-
import { E as EMPTY_ARGS, a as EMPTY_NAMED, b as EMPTY_POSITIONAL } from './arguments-
|
|
5
|
+
import { E as EMPTY_ARGS, a as EMPTY_NAMED, b as EMPTY_POSITIONAL } from './arguments-DxmU3uk4.js';
|
|
6
6
|
|
|
7
7
|
function getArgs(proxy) {
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toBool } from '../@glimmer/global-context/index.js';
|
|
2
2
|
import { c as createComputeRef, v as valueForRef } from './reference-CG0yPgLy.js';
|
|
3
|
-
import { i as internalHelper } from './hash-
|
|
3
|
+
import { i as internalHelper } from './hash-BPZcn79q.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Performs a strict equality comparison.
|