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
|
@@ -815,7 +815,11 @@ APPEND_OPCODES.add(VM_DYNAMIC_MODIFIER_OP, vm => {
|
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
817
|
if (!isConstRef(ref) || tag) {
|
|
818
|
-
|
|
818
|
+
let updateOpcode = new UpdateDynamicModifierOpcode(tag, instance, instanceRef);
|
|
819
|
+
|
|
820
|
+
// The block must own this opcode, or instances created on update are never destroyed.
|
|
821
|
+
vm.associateDestroyable(updateOpcode);
|
|
822
|
+
return vm.updateWith(updateOpcode);
|
|
819
823
|
}
|
|
820
824
|
});
|
|
821
825
|
class UpdateModifierOpcode {
|
|
@@ -4,7 +4,7 @@ import { getViewElement, clearElementView, clearViewElement, addChildView, setVi
|
|
|
4
4
|
import { debugFreeze } from '../@ember/debug/index.js';
|
|
5
5
|
import { _instrumentStart } from '../@ember/instrumentation/index.js';
|
|
6
6
|
import { c as createComputeRef, v as valueForRef, e as createPrimitiveRef, f as childRefFor, g as childRefFromParts, a as createConstRef, d as isUpdatableRef, u as updateRef } from './reference-BqOLhKFy.js';
|
|
7
|
-
import { f as reifyPositional } from './arguments-
|
|
7
|
+
import { f as reifyPositional } from './arguments-BDcCvRM4.js';
|
|
8
8
|
import { E as EMPTY_ARRAY } from './array-utils-CZQxrdD3.js';
|
|
9
9
|
import { a as valueForTag, p as beginUntrackFrame, w as endUntrackFrame, o as beginTrackFrame, s as endTrackFrame, c as consumeTag, v as validateTag } from './cache-DGDPVCpC.js';
|
|
10
10
|
import { g as get } from './property_get-CRP7MFz_.js';
|
|
@@ -67,30 +67,6 @@ function getElementDefinition(tagName) {
|
|
|
67
67
|
|
|
68
68
|
// ============ Element Helper ============
|
|
69
69
|
|
|
70
|
-
/**
|
|
71
|
-
The `element` helper lets you dynamically set the tag name of an element.
|
|
72
|
-
|
|
73
|
-
```handlebars
|
|
74
|
-
{{#let (element @tagName) as |Tag|}}
|
|
75
|
-
<Tag class="my-element">Hello</Tag>
|
|
76
|
-
{{/let}}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
When `@tagName` is `"h1"`, this renders `<h1 class="my-element">Hello</h1>`.
|
|
80
|
-
|
|
81
|
-
When `@tagName` is an empty string `""`, the block content is rendered without
|
|
82
|
-
a wrapping element.
|
|
83
|
-
|
|
84
|
-
Passing `null`, `undefined`, or non-string values will throw an assertion error.
|
|
85
|
-
|
|
86
|
-
Changing the tag name will tear down and recreate the element and its contents.
|
|
87
|
-
|
|
88
|
-
The `element` helper is built-in and does not need to be imported.
|
|
89
|
-
|
|
90
|
-
@method element
|
|
91
|
-
@for Ember.Templates.helpers
|
|
92
|
-
@public
|
|
93
|
-
*/
|
|
94
70
|
const element = internalHelper(({
|
|
95
71
|
positional,
|
|
96
72
|
named
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { c as createComputeRef, U as UNDEFINED_REFERENCE, v as valueForRef } from './reference-BqOLhKFy.js';
|
|
2
|
+
import { f as reifyPositional } from './arguments-BDcCvRM4.js';
|
|
3
|
+
import { i as internalHelper } from './hash-CKwikdMv.js';
|
|
4
|
+
import { setPath, getPath } from '../@glimmer/global-context/index.js';
|
|
5
|
+
import { i as isDict } from './collections-DPkjqeA3.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, b as isInvokableRef, u as updateRef, v as valueForRef } from './reference-BqOLhKFy.js';
|
|
2
|
+
import { f as reifyPositional, g as buildUntouchableThis, h as check, e as reifyNamed } from './arguments-BDcCvRM4.js';
|
|
3
|
+
import { j as setInternalHelperManager } from './api-DuLOZMO_.js';
|
|
4
|
+
|
|
5
|
+
function internalHelper(helper) {
|
|
6
|
+
return setInternalHelperManager(helper, {});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const array = internalHelper(({
|
|
10
|
+
positional
|
|
11
|
+
}) => {
|
|
12
|
+
return createComputeRef(() => reifyPositional(positional), null, 'array');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const context = buildUntouchableThis('`fn` helper');
|
|
16
|
+
const fn = internalHelper(({
|
|
17
|
+
positional
|
|
18
|
+
}) => {
|
|
19
|
+
let callbackRef = check(positional[0]);
|
|
20
|
+
return createComputeRef(() => {
|
|
21
|
+
return (...invocationArgs) => {
|
|
22
|
+
let [fn, ...args] = reifyPositional(positional);
|
|
23
|
+
assertCallbackIsFn(callbackRef);
|
|
24
|
+
if (isInvokableRef(callbackRef)) {
|
|
25
|
+
let value = args.length > 0 ? args[0] : invocationArgs[0];
|
|
26
|
+
return void updateRef(callbackRef, value);
|
|
27
|
+
} else {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return -- @fixme
|
|
29
|
+
return fn.call(context, ...args, ...invocationArgs);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}, null, 'fn');
|
|
33
|
+
});
|
|
34
|
+
function assertCallbackIsFn(callbackRef) {
|
|
35
|
+
if (!(callbackRef && (isInvokableRef(callbackRef) || typeof valueForRef(callbackRef) === 'function'))) {
|
|
36
|
+
throw new Error(`You must pass a function as the \`fn\` helper's first argument, you passed ${callbackRef ? valueForRef(callbackRef) : callbackRef}. While rendering:\n\n${callbackRef?.debugLabel}`);
|
|
37
|
+
}
|
|
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 };
|
|
@@ -29,7 +29,7 @@ const IS_CLASSIC_HELPER = Symbol('IS_CLASSIC_HELPER');
|
|
|
29
29
|
Ember Helpers are functions that can compute values, and are used in templates.
|
|
30
30
|
For example, this code calls a helper named `format-currency`:
|
|
31
31
|
|
|
32
|
-
```app/templates/application.gjs
|
|
32
|
+
```gjs {data-filename="app/templates/application.gjs"}
|
|
33
33
|
import Cost from '../components/cost';
|
|
34
34
|
|
|
35
35
|
<template>
|
|
@@ -37,7 +37,7 @@ const IS_CLASSIC_HELPER = Symbol('IS_CLASSIC_HELPER');
|
|
|
37
37
|
</template>
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
```app/components/cost.gjs
|
|
40
|
+
```gjs {data-filename="app/components/cost.gjs"}
|
|
41
41
|
import formatCurrency from '../helpers/format-currency';
|
|
42
42
|
|
|
43
43
|
<template>
|
|
@@ -10,10 +10,10 @@ import { artifacts } from '../@glimmer/program/index.js';
|
|
|
10
10
|
import { R as RuntimeOpImpl } from './program-DlgjqLa6.js';
|
|
11
11
|
import { v as valueForRef, U as UNDEFINED_REFERENCE, c as createComputeRef, i as isConstRef, a as createConstRef, d as isUpdatableRef, j as createInvokableRef, k as createReadOnlyRef, l as createUnboundRef, h as createDebugAliasRef, g as childRefFromParts, u as updateRef } from './reference-BqOLhKFy.js';
|
|
12
12
|
import { c as clientBuilder } from './api-C0PAtEgQ.js';
|
|
13
|
-
import { E as EMPTY_ARGS, c as createCapturedArgs, b as EMPTY_POSITIONAL, d as curry } from './arguments-
|
|
14
|
-
import { g as runtimeOptions, i as inTransaction, r as renderComponent$1, d as renderMain } from './render-
|
|
13
|
+
import { E as EMPTY_ARGS, c as createCapturedArgs, b as EMPTY_POSITIONAL, d as curry } from './arguments-BDcCvRM4.js';
|
|
14
|
+
import { g as runtimeOptions, i as inTransaction, r as renderComponent$1, d as renderMain } from './render-WPz2Nl45.js';
|
|
15
15
|
import { d as dict } from './collections-DPkjqeA3.js';
|
|
16
|
-
import { u as unwrapTemplate, a as CurlyComponentManager, i as initialRenderInstrumentDetails, p as processComponentInitializationAssertions, b as ComponentStateBucket, D as DIRTY_TAG, c as isCurlyManager, B as BOUNDS } from './curly-
|
|
16
|
+
import { u as unwrapTemplate, a as CurlyComponentManager, i as initialRenderInstrumentDetails, p as processComponentInitializationAssertions, b as ComponentStateBucket, D as DIRTY_TAG, c as isCurlyManager, B as BOUNDS } from './curly-CxVJYzMX.js';
|
|
17
17
|
import { C as CONSTANT_TAG, c as consumeTag, z as isTracking, e as debug, D as DIRTY_TAG$1, r as createTag, a as valueForTag, k as CURRENT_TAG, v as validateTag } from './cache-DGDPVCpC.js';
|
|
18
18
|
import { h as hasDOM } from './index-BGP1rw3B.js';
|
|
19
19
|
import { _instrumentStart } from '../@ember/instrumentation/index.js';
|
|
@@ -36,13 +36,13 @@ import { i as isHTMLSafe } from './index-D-xTBV4B.js';
|
|
|
36
36
|
import isArray from '../@ember/array/lib/is-array.js';
|
|
37
37
|
import { g as getComponentTemplate } from './template-R_5UMHhb.js';
|
|
38
38
|
import { c as hasInternalComponentManager, j as setInternalHelperManager, g as getInternalComponentManager } from './api-DuLOZMO_.js';
|
|
39
|
-
import { h as hash, f as fn, a as array } from './hash-
|
|
40
|
-
import { g as get$1, c as concat } from './get-
|
|
41
|
-
import { o as on } from './on-
|
|
39
|
+
import { h as hash, f as fn, a as array } from './hash-CKwikdMv.js';
|
|
40
|
+
import { g as get$1, c as concat } from './get-BAZ7dSW_.js';
|
|
41
|
+
import { o as on } from './on-CsI9Xgvl.js';
|
|
42
42
|
import { T as TEMPLATE_ONLY_COMPONENT_MANAGER, t as templateOnlyComponent } from './template-only-Cu639ICT.js';
|
|
43
|
-
import { i as isClassicHelper, C as CLASSIC_HELPER_MANAGER } from './helper
|
|
43
|
+
import { i as isClassicHelper, C as CLASSIC_HELPER_MANAGER } from './helper--ZiOCQkd.js';
|
|
44
44
|
import { dasherize } from '../@ember/-internals/string/index.js';
|
|
45
|
-
import { a as uniqueId } from './unique-id-
|
|
45
|
+
import { a as uniqueId } from './unique-id-Csxuh1I7.js';
|
|
46
46
|
import { generateControllerFactory } from '../@ember/routing/lib/generate_controller.js';
|
|
47
47
|
import { E as EvaluationContextImpl } from './program-context-Dq8xN2HI.js';
|
|
48
48
|
|
|
@@ -238,7 +238,7 @@ class RootComponentDefinition {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/**
|
|
241
|
-
@module ember
|
|
241
|
+
@module @ember/helper
|
|
242
242
|
*/
|
|
243
243
|
|
|
244
244
|
/**
|
|
@@ -248,46 +248,91 @@ class RootComponentDefinition {
|
|
|
248
248
|
The default behavior of `{{#each}}` is to yield its inner block once for every
|
|
249
249
|
item in an array passing the item as the first block parameter.
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
```gjs {data-filename="app/components/developer-list.gjs"}
|
|
252
|
+
import Component from '@glimmer/component';
|
|
252
253
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
export default class DeveloperList extends Component {
|
|
255
|
+
developers = [
|
|
256
|
+
{ name: 'Yehuda' },
|
|
257
|
+
{ name: 'Tom' },
|
|
258
|
+
{ name: 'Paul' },
|
|
259
|
+
];
|
|
256
260
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
<template>
|
|
262
|
+
<ul>
|
|
263
|
+
{{#each this.developers as |person|}}
|
|
264
|
+
<li>Hello, {{person.name}}!</li>
|
|
265
|
+
{{/each}}
|
|
266
|
+
</ul>
|
|
267
|
+
</template>
|
|
268
|
+
}
|
|
263
269
|
```
|
|
264
270
|
|
|
265
|
-
The same rules apply to arrays of primitives
|
|
271
|
+
The same rules apply to arrays of primitives:
|
|
272
|
+
|
|
273
|
+
```app/components/developer-names.gjs
|
|
274
|
+
import Component from '@glimmer/component';
|
|
275
|
+
|
|
276
|
+
export default class DeveloperNames extends Component {
|
|
277
|
+
developerNames = ['Yehuda', 'Tom', 'Paul'];
|
|
266
278
|
|
|
267
|
-
|
|
268
|
-
|
|
279
|
+
<template>
|
|
280
|
+
<ul>
|
|
281
|
+
{{#each this.developerNames as |name|}}
|
|
282
|
+
<li>Hello, {{name}}!</li>
|
|
283
|
+
{{/each}}
|
|
284
|
+
</ul>
|
|
285
|
+
</template>
|
|
286
|
+
}
|
|
269
287
|
```
|
|
270
288
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
289
|
+
`{{#each}}` also supports native JavaScript [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
|
|
290
|
+
values and other iterables:
|
|
291
|
+
|
|
292
|
+
```gjs {data-filename="app/components/developer-set.gjs"}
|
|
293
|
+
import Component from '@glimmer/component';
|
|
294
|
+
|
|
295
|
+
export default class DeveloperSet extends Component {
|
|
296
|
+
developers = new Set([
|
|
297
|
+
{ name: 'Yehuda' },
|
|
298
|
+
{ name: 'Tom' },
|
|
299
|
+
{ name: 'Paul' },
|
|
300
|
+
]);
|
|
301
|
+
|
|
302
|
+
<template>
|
|
303
|
+
<ul>
|
|
304
|
+
{{#each this.developers as |person|}}
|
|
305
|
+
<li>Hello, {{person.name}}!</li>
|
|
306
|
+
{{/each}}
|
|
307
|
+
</ul>
|
|
308
|
+
</template>
|
|
309
|
+
}
|
|
277
310
|
```
|
|
278
311
|
|
|
279
|
-
During iteration, the index of each item in the array is provided as a second
|
|
280
|
-
parameter
|
|
312
|
+
During iteration, the index of each item in the array is provided as a second
|
|
313
|
+
block parameter:
|
|
281
314
|
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
315
|
+
```app/components/developer-list-with-index.gjs
|
|
316
|
+
import Component from '@glimmer/component';
|
|
317
|
+
|
|
318
|
+
export default class DeveloperListWithIndex extends Component {
|
|
319
|
+
developers = [
|
|
320
|
+
{ name: 'Yehuda' },
|
|
321
|
+
{ name: 'Tom' },
|
|
322
|
+
{ name: 'Paul' },
|
|
323
|
+
];
|
|
324
|
+
|
|
325
|
+
<template>
|
|
326
|
+
<ul>
|
|
327
|
+
{{#each this.developers as |person index|}}
|
|
328
|
+
<li>Hello, {{person.name}}! You're number {{index}} in line</li>
|
|
329
|
+
{{/each}}
|
|
330
|
+
</ul>
|
|
331
|
+
</template>
|
|
332
|
+
}
|
|
288
333
|
```
|
|
289
|
-
|
|
290
|
-
`#each` is a keyword and does not need to be imported.
|
|
334
|
+
|
|
335
|
+
`#each` is a keyword and does not need to be imported.
|
|
291
336
|
|
|
292
337
|
### Specifying Keys
|
|
293
338
|
|
|
@@ -303,30 +348,38 @@ class RootComponentDefinition {
|
|
|
303
348
|
needed. However, in some rare cases, the objects' identities may change even
|
|
304
349
|
though they represent the same underlying data.
|
|
305
350
|
|
|
306
|
-
For example
|
|
351
|
+
For example, mapping over `people` produces a new array of new objects on each
|
|
352
|
+
render. Use `key` so Ember can match items across those renders:
|
|
307
353
|
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
return { ...person, type: 'developer' };
|
|
311
|
-
});
|
|
312
|
-
```
|
|
354
|
+
```gjs {data-filename="app/components/mapped-developers.gjs"}
|
|
355
|
+
import Component from '@glimmer/component';
|
|
313
356
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
357
|
+
export default class MappedDevelopers extends Component {
|
|
358
|
+
people = [
|
|
359
|
+
{ name: 'Yehuda' },
|
|
360
|
+
{ name: 'Tom' },
|
|
361
|
+
{ name: 'Paul' },
|
|
362
|
+
];
|
|
318
363
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
364
|
+
get developers() {
|
|
365
|
+
return this.people.map((person) => {
|
|
366
|
+
return { ...person, type: 'developer' };
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
<template>
|
|
371
|
+
<ul>
|
|
372
|
+
{{#each this.developers key="name" as |person|}}
|
|
373
|
+
<li>Hello, {{person.name}}!</li>
|
|
374
|
+
{{/each}}
|
|
375
|
+
</ul>
|
|
376
|
+
</template>
|
|
377
|
+
}
|
|
325
378
|
```
|
|
326
379
|
|
|
327
380
|
By doing so, Ember will use the value of the property specified (`person.name`
|
|
328
381
|
in the example) to find a "match" from the previous render. That is, if Ember
|
|
329
|
-
has previously seen an object from the
|
|
382
|
+
has previously seen an object from the `developers` array with a matching
|
|
330
383
|
name, its DOM elements will be re-used.
|
|
331
384
|
|
|
332
385
|
There are two special values for `key`:
|
|
@@ -339,36 +392,47 @@ class RootComponentDefinition {
|
|
|
339
392
|
`{{#each}}` can have a matching `{{else}}`. The contents of this block will render
|
|
340
393
|
if the collection is empty.
|
|
341
394
|
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
395
|
+
```gjs {data-filename="app/components/available-developers.gjs"}
|
|
396
|
+
import Component from '@glimmer/component';
|
|
397
|
+
|
|
398
|
+
export default class AvailableDevelopers extends Component {
|
|
399
|
+
developers = [];
|
|
400
|
+
|
|
401
|
+
<template>
|
|
402
|
+
<ul>
|
|
403
|
+
{{#each this.developers as |person|}}
|
|
404
|
+
<li>{{person.name}} is available!</li>
|
|
405
|
+
{{else}}
|
|
406
|
+
<li>Sorry, nobody is available for this task.</li>
|
|
407
|
+
{{/each}}
|
|
408
|
+
</ul>
|
|
409
|
+
</template>
|
|
410
|
+
}
|
|
350
411
|
```
|
|
351
412
|
|
|
352
413
|
@method each
|
|
353
|
-
@for
|
|
414
|
+
@for Keywords
|
|
415
|
+
@static
|
|
416
|
+
@noimport
|
|
354
417
|
@public
|
|
355
418
|
*/
|
|
356
419
|
|
|
357
420
|
/**
|
|
358
|
-
The `{{#each-in}}` keyword loops over properties on an object
|
|
421
|
+
The `{{#each-in}}` keyword loops over properties on an object, or entries in a
|
|
422
|
+
native JavaScript [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map).
|
|
359
423
|
|
|
360
424
|
For example, given this component definition:
|
|
361
425
|
|
|
362
|
-
```app/components/developer-details.gjs
|
|
426
|
+
```gjs {data-filename="app/components/developer-details.gjs"}
|
|
363
427
|
import Component from '@glimmer/component';
|
|
364
428
|
import { tracked } from '@glimmer/tracking';
|
|
365
429
|
|
|
366
|
-
export default class extends Component {
|
|
430
|
+
export default class DeveloperDetails extends Component {
|
|
367
431
|
@tracked developer = {
|
|
368
|
-
|
|
369
|
-
|
|
432
|
+
name: 'Shelly Sails',
|
|
433
|
+
age: 42,
|
|
370
434
|
};
|
|
371
|
-
|
|
435
|
+
|
|
372
436
|
<template>
|
|
373
437
|
<ul>
|
|
374
438
|
{{#each-in this.developer as |key value|}}
|
|
@@ -388,11 +452,56 @@ class RootComponentDefinition {
|
|
|
388
452
|
<li>age: 42</li>
|
|
389
453
|
</ul>
|
|
390
454
|
```
|
|
391
|
-
|
|
455
|
+
|
|
456
|
+
The same pattern works with a `Map`:
|
|
457
|
+
|
|
458
|
+
```gjs {data-filename="app/components/developer-map.gjs"}
|
|
459
|
+
import Component from '@glimmer/component';
|
|
460
|
+
|
|
461
|
+
export default class DeveloperMap extends Component {
|
|
462
|
+
map = new Map([
|
|
463
|
+
['name', 'Shelly Sails'],
|
|
464
|
+
['age', 42],
|
|
465
|
+
]);
|
|
466
|
+
|
|
467
|
+
<template>
|
|
468
|
+
<ul>
|
|
469
|
+
{{#each-in this.map as |key value|}}
|
|
470
|
+
<li>{{key}}: {{value}}</li>
|
|
471
|
+
{{/each-in}}
|
|
472
|
+
</ul>
|
|
473
|
+
</template>
|
|
474
|
+
}
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
When a `Map` uses object keys, you can pass `key="@identity"` to explicitly
|
|
478
|
+
track entries across re-renders using the JavaScript identity of each key:
|
|
479
|
+
|
|
480
|
+
```gjs {data-filename="app/components/object-keyed-map.gjs"}
|
|
481
|
+
import Component from '@glimmer/component';
|
|
482
|
+
|
|
483
|
+
export default class ObjectKeyedMap extends Component {
|
|
484
|
+
map = new Map([
|
|
485
|
+
[{ name: 'one' }, 'foo'],
|
|
486
|
+
[{ name: 'two' }, 'bar'],
|
|
487
|
+
]);
|
|
488
|
+
|
|
489
|
+
<template>
|
|
490
|
+
<ul>
|
|
491
|
+
{{#each-in this.map key="@identity" as |key value|}}
|
|
492
|
+
<li>{{key.name}}: {{value}}</li>
|
|
493
|
+
{{/each-in}}
|
|
494
|
+
</ul>
|
|
495
|
+
</template>
|
|
496
|
+
}
|
|
497
|
+
```
|
|
498
|
+
|
|
392
499
|
`#each-in` is a keyword and does not need to be imported.
|
|
393
500
|
|
|
394
501
|
@method each-in
|
|
395
|
-
@
|
|
502
|
+
@static
|
|
503
|
+
@noimport
|
|
504
|
+
@for Keywords
|
|
396
505
|
@public
|
|
397
506
|
@since 2.1.0
|
|
398
507
|
*/
|
|
@@ -855,7 +964,7 @@ const trackArray = internalHelper(({
|
|
|
855
964
|
});
|
|
856
965
|
|
|
857
966
|
/**
|
|
858
|
-
@module ember
|
|
967
|
+
@module @ember/helper
|
|
859
968
|
*/
|
|
860
969
|
|
|
861
970
|
/**
|
|
@@ -875,7 +984,7 @@ const trackArray = internalHelper(({
|
|
|
875
984
|
|
|
876
985
|
The child `Component` would invoke the function with the new click count:
|
|
877
986
|
|
|
878
|
-
```app/components/my-child.gjs
|
|
987
|
+
```gjs {data-filename="app/components/my-child.gjs"}
|
|
879
988
|
import Component from '@glimmer/component';
|
|
880
989
|
import { action } from '@ember/object';
|
|
881
990
|
|
|
@@ -897,7 +1006,8 @@ const trackArray = internalHelper(({
|
|
|
897
1006
|
|
|
898
1007
|
@method mut
|
|
899
1008
|
@param {Object} [attr] the "two-way" attribute that can be modified.
|
|
900
|
-
@
|
|
1009
|
+
@static
|
|
1010
|
+
@for Keywords
|
|
901
1011
|
@public
|
|
902
1012
|
*/
|
|
903
1013
|
|
|
@@ -922,7 +1032,7 @@ const mut = internalHelper(({
|
|
|
922
1032
|
});
|
|
923
1033
|
|
|
924
1034
|
/**
|
|
925
|
-
@module ember
|
|
1035
|
+
@module @ember/helper
|
|
926
1036
|
*/
|
|
927
1037
|
|
|
928
1038
|
|
|
@@ -1034,7 +1144,9 @@ const mut = internalHelper(({
|
|
|
1034
1144
|
|
|
1035
1145
|
@method readonly
|
|
1036
1146
|
@param {Object} [attr] the read-only attribute.
|
|
1037
|
-
@for
|
|
1147
|
+
@for Keywords
|
|
1148
|
+
@noimport
|
|
1149
|
+
@static
|
|
1038
1150
|
@private
|
|
1039
1151
|
*/
|
|
1040
1152
|
const readonly = internalHelper(({
|
|
@@ -1046,7 +1158,7 @@ const readonly = internalHelper(({
|
|
|
1046
1158
|
});
|
|
1047
1159
|
|
|
1048
1160
|
/**
|
|
1049
|
-
@module ember
|
|
1161
|
+
@module @ember/helper
|
|
1050
1162
|
*/
|
|
1051
1163
|
|
|
1052
1164
|
|
|
@@ -1072,9 +1184,13 @@ const readonly = internalHelper(({
|
|
|
1072
1184
|
|
|
1073
1185
|
The `unbound` helper only accepts a single argument, and it return an
|
|
1074
1186
|
unbound value.
|
|
1187
|
+
|
|
1188
|
+
`unbound` is a template keyword and does not need to be imported.
|
|
1075
1189
|
|
|
1076
1190
|
@method unbound
|
|
1077
|
-
@
|
|
1191
|
+
@static
|
|
1192
|
+
@noimport
|
|
1193
|
+
@for Keywords
|
|
1078
1194
|
@public
|
|
1079
1195
|
*/
|
|
1080
1196
|
|
|
@@ -1217,7 +1333,7 @@ class MountDefinition {
|
|
|
1217
1333
|
}
|
|
1218
1334
|
|
|
1219
1335
|
/**
|
|
1220
|
-
@module ember
|
|
1336
|
+
@module @ember/helper
|
|
1221
1337
|
*/
|
|
1222
1338
|
|
|
1223
1339
|
|
|
@@ -1228,7 +1344,7 @@ class MountDefinition {
|
|
|
1228
1344
|
|
|
1229
1345
|
For example, the following template mounts the `ember-chat` engine:
|
|
1230
1346
|
|
|
1231
|
-
```app/templates/application.gjs
|
|
1347
|
+
```gjs {data-filename="app/templates/application.gjs"}
|
|
1232
1348
|
{{mount "ember-chat"}}
|
|
1233
1349
|
```
|
|
1234
1350
|
|
|
@@ -1262,7 +1378,9 @@ class MountDefinition {
|
|
|
1262
1378
|
@param {String} name Name of the engine to mount.
|
|
1263
1379
|
@param {Object} [model] Object that will be set as
|
|
1264
1380
|
the model of the engine.
|
|
1265
|
-
@for
|
|
1381
|
+
@for Keywords
|
|
1382
|
+
@static
|
|
1383
|
+
@noimport
|
|
1266
1384
|
@public
|
|
1267
1385
|
*/
|
|
1268
1386
|
const mountHelper = internalHelper((args, owner) => {
|
|
@@ -1397,12 +1515,16 @@ function makeRouteTemplate(owner, name, template) {
|
|
|
1397
1515
|
return curry(0, routeTemplate, owner, null, true);
|
|
1398
1516
|
}
|
|
1399
1517
|
|
|
1518
|
+
/**
|
|
1519
|
+
@module @ember/helper
|
|
1520
|
+
*/
|
|
1521
|
+
|
|
1400
1522
|
/**
|
|
1401
1523
|
The `{{outlet}}` helper lets you specify where a child route will render in
|
|
1402
1524
|
your template. An important use of the `{{outlet}}` helper is in your
|
|
1403
1525
|
application's `application.gjs` file:
|
|
1404
1526
|
|
|
1405
|
-
```app/templates/application.gjs
|
|
1527
|
+
```gjs {data-filename="app/templates/application.gjs"}
|
|
1406
1528
|
import MyHeader from '../components/my-header';
|
|
1407
1529
|
import MyFooter from '../components/my-footer';
|
|
1408
1530
|
|
|
@@ -1425,7 +1547,9 @@ function makeRouteTemplate(owner, name, template) {
|
|
|
1425
1547
|
`outlet` is built-in and does not need to be imported.
|
|
1426
1548
|
|
|
1427
1549
|
@method outlet
|
|
1428
|
-
@for
|
|
1550
|
+
@for Keywords
|
|
1551
|
+
@static
|
|
1552
|
+
@noimport
|
|
1429
1553
|
@public
|
|
1430
1554
|
*/
|
|
1431
1555
|
const outletHelper = internalHelper((_args, owner, scope) => {
|
|
@@ -2,7 +2,7 @@ import { isDestroying, isDestroyed, associateDestroyableChild } from '../@glimme
|
|
|
2
2
|
import { a as getInternalHelperManager, f as hasValue, h as hasDestroyable } from './api-DuLOZMO_.js';
|
|
3
3
|
import { getOwner } from '../@glimmer/owner/index.js';
|
|
4
4
|
import { g as createCache, h as getValue } from './cache-DGDPVCpC.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-BDcCvRM4.js';
|
|
6
6
|
|
|
7
7
|
let ARGS_CACHES = new WeakMap() ;
|
|
8
8
|
function getArgs(proxy) {
|
|
@@ -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-BqOLhKFy.js';
|
|
3
|
-
import { i as internalHelper } from './hash-
|
|
3
|
+
import { i as internalHelper } from './hash-CKwikdMv.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Performs a strict equality comparison.
|