ember-source 4.4.0-alpha.2 → 4.4.0-alpha.5
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/CHANGELOG.md +5 -1
- package/blueprints/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.js +1 -1
- package/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +1 -1
- package/blueprints/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +1 -1
- package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +1 -1
- package/blueprints/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +19 -8
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +9 -5
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +994 -1537
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +0 -16
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +10 -19
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +113 -112
- package/dist/packages/@ember/-internals/glimmer/index.js +150 -749
- package/dist/packages/@ember/-internals/metal/index.js +6 -17
- package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +1 -1
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +65 -12
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +1 -1
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +11 -8
- package/dist/packages/@ember/-internals/runtime/lib/compare.js +19 -5
- package/dist/packages/@ember/-internals/runtime/lib/ext/rsvp.js +8 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +4 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +16 -16
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +8 -8
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +4 -2
- package/dist/packages/@ember/-internals/views/lib/views/core_view.js +5 -22
- package/dist/packages/@ember/canary-features/index.js +4 -2
- package/dist/packages/@ember/debug/index.js +1 -1
- package/dist/packages/@ember/debug/lib/deprecate.js +6 -2
- package/dist/packages/@ember/debug/lib/handlers.js +1 -1
- package/dist/packages/@ember/renderer/index.js +21 -0
- package/dist/packages/@ember/runloop/index.js +31 -528
- package/dist/packages/@ember/runloop/type-tests.ts/begin-end.test.js +5 -0
- package/dist/packages/@ember/runloop/type-tests.ts/bind.test.js +59 -0
- package/dist/packages/@ember/runloop/type-tests.ts/cancel.test.js +5 -0
- package/dist/packages/@ember/runloop/type-tests.ts/debounce.test.js +77 -0
- package/dist/packages/@ember/runloop/type-tests.ts/join.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/later.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/next.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/once.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/run.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/schedule-once.test.js +39 -0
- package/dist/packages/@ember/runloop/type-tests.ts/schedule.test.js +39 -0
- package/dist/packages/@ember/runloop/type-tests.ts/throttle.test.js +77 -0
- package/dist/packages/ember/index.js +1 -0
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +591 -300
- package/package.json +11 -11
|
@@ -300,7 +300,7 @@ class ForkedValue {
|
|
|
300
300
|
class AbstractInput extends InternalComponent {
|
|
301
301
|
constructor() {
|
|
302
302
|
super(...arguments);
|
|
303
|
-
this._value = valueFrom(this.args.named
|
|
303
|
+
this._value = valueFrom(this.args.named['value']);
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
validateArguments() {
|
|
@@ -555,7 +555,7 @@ if (hasDOM) {
|
|
|
555
555
|
class Input extends AbstractInput {
|
|
556
556
|
constructor() {
|
|
557
557
|
super(...arguments);
|
|
558
|
-
this._checked = valueFrom(this.args.named
|
|
558
|
+
this._checked = valueFrom(this.args.named['checked']);
|
|
559
559
|
}
|
|
560
560
|
|
|
561
561
|
static toString() {
|
|
@@ -595,7 +595,7 @@ class Input extends AbstractInput {
|
|
|
595
595
|
|
|
596
596
|
get checked() {
|
|
597
597
|
if (this.isCheckbox) {
|
|
598
|
-
warn('`<Input @type="checkbox" />` reflects its checked state via the `@checked` argument. ' + 'You wrote `<Input @type="checkbox" @value={{...}} />` which is likely not what you intended. ' + 'Did you mean `<Input @type="checkbox" @checked={{...}} />`?', untrack(() => this.args.named
|
|
598
|
+
warn('`<Input @type="checkbox" />` reflects its checked state via the `@checked` argument. ' + 'You wrote `<Input @type="checkbox" @value={{...}} />` which is likely not what you intended. ' + 'Did you mean `<Input @type="checkbox" @checked={{...}} />`?', untrack(() => this.args.named['checked'] !== undefined || this.args.named['value'] === undefined || typeof valueForRef(this.args.named['value']) === 'string'), {
|
|
599
599
|
id: 'ember.built-in-components.input-checkbox-value'
|
|
600
600
|
});
|
|
601
601
|
return this._checked.get();
|
|
@@ -605,7 +605,7 @@ class Input extends AbstractInput {
|
|
|
605
605
|
}
|
|
606
606
|
|
|
607
607
|
set checked(checked) {
|
|
608
|
-
warn('`<Input @type="checkbox" />` reflects its checked state via the `@checked` argument. ' + 'You wrote `<Input @type="checkbox" @value={{...}} />` which is likely not what you intended. ' + 'Did you mean `<Input @type="checkbox" @checked={{...}} />`?', untrack(() => this.args.named
|
|
608
|
+
warn('`<Input @type="checkbox" />` reflects its checked state via the `@checked` argument. ' + 'You wrote `<Input @type="checkbox" @value={{...}} />` which is likely not what you intended. ' + 'Did you mean `<Input @type="checkbox" @checked={{...}} />`?', untrack(() => this.args.named['checked'] !== undefined || this.args.named['value'] === undefined || typeof valueForRef(this.args.named['value']) === 'string'), {
|
|
609
609
|
id: 'ember.built-in-components.input-checkbox-value'
|
|
610
610
|
});
|
|
611
611
|
|
|
@@ -1898,8 +1898,8 @@ var action$1 = internalHelper(args => {
|
|
|
1898
1898
|
let [context, action$$1, ...restArgs] = positional;
|
|
1899
1899
|
assert('hash position arguments', context && action$$1);
|
|
1900
1900
|
let debugKey = action$$1.debugLabel;
|
|
1901
|
-
let target = 'target' in named
|
|
1902
|
-
let processArgs = makeArgsProcessor('value' in named && named
|
|
1901
|
+
let target = 'target' in named ? named['target'] : context;
|
|
1902
|
+
let processArgs = makeArgsProcessor('value' in named && named['value'] || false, restArgs);
|
|
1903
1903
|
let fn$$1;
|
|
1904
1904
|
|
|
1905
1905
|
if (isInvokableRef(action$$1)) {
|
|
@@ -1963,13 +1963,12 @@ function makeClosureAction(context, target, action$$1, processArgs, debugKey) {
|
|
|
1963
1963
|
let self;
|
|
1964
1964
|
let fn$$1;
|
|
1965
1965
|
assert(`Action passed is null or undefined in (action) from ${target}.`, action$$1 !== undefined && action$$1 !== null);
|
|
1966
|
-
let typeofAction = typeof action$$1;
|
|
1967
1966
|
|
|
1968
|
-
if (
|
|
1967
|
+
if (typeof action$$1 === 'string') {
|
|
1969
1968
|
self = target;
|
|
1970
1969
|
fn$$1 = target.actions && target.actions[action$$1];
|
|
1971
1970
|
assert(`An action named '${action$$1}' was not found in ${target}`, Boolean(fn$$1));
|
|
1972
|
-
} else if (
|
|
1971
|
+
} else if (typeof action$$1 === 'function') {
|
|
1973
1972
|
self = context;
|
|
1974
1973
|
fn$$1 = action$$1;
|
|
1975
1974
|
} else {
|
|
@@ -2493,625 +2492,6 @@ function isCurlyManager(manager) {
|
|
|
2493
2492
|
}
|
|
2494
2493
|
|
|
2495
2494
|
let lazyEventsProcessed = new WeakMap();
|
|
2496
|
-
/**
|
|
2497
|
-
@module @ember/component
|
|
2498
|
-
*/
|
|
2499
|
-
|
|
2500
|
-
/**
|
|
2501
|
-
A component is a reusable UI element that consists of a `.hbs` template and an
|
|
2502
|
-
optional JavaScript class that defines its behavior. For example, someone
|
|
2503
|
-
might make a `button` in the template and handle the click behavior in the
|
|
2504
|
-
JavaScript file that shares the same name as the template.
|
|
2505
|
-
|
|
2506
|
-
Components are broken down into two categories:
|
|
2507
|
-
|
|
2508
|
-
- Components _without_ JavaScript, that are based only on a template. These
|
|
2509
|
-
are called Template-only or TO components.
|
|
2510
|
-
- Components _with_ JavaScript, which consist of a template and a backing
|
|
2511
|
-
class.
|
|
2512
|
-
|
|
2513
|
-
Ember ships with two types of JavaScript classes for components:
|
|
2514
|
-
|
|
2515
|
-
1. Glimmer components, imported from `@glimmer/component`, which are the
|
|
2516
|
-
default component's for Ember Octane (3.15) and more recent editions.
|
|
2517
|
-
2. Classic components, imported from `@ember/component`, which were the
|
|
2518
|
-
default for older editions of Ember (pre 3.15).
|
|
2519
|
-
|
|
2520
|
-
Below is the documentation for Classic components. If you are looking for the
|
|
2521
|
-
API documentation for Template-only or Glimmer components, it is
|
|
2522
|
-
[available here](/ember/release/modules/@glimmer%2Fcomponent).
|
|
2523
|
-
|
|
2524
|
-
## Defining a Classic Component
|
|
2525
|
-
|
|
2526
|
-
If you want to customize the component in order to handle events, transform
|
|
2527
|
-
arguments or maintain internal state, you implement a subclass of `Component`.
|
|
2528
|
-
|
|
2529
|
-
One example is to add computed properties to your component:
|
|
2530
|
-
|
|
2531
|
-
```app/components/person-profile.js
|
|
2532
|
-
import Component from '@ember/component';
|
|
2533
|
-
|
|
2534
|
-
export default Component.extend({
|
|
2535
|
-
displayName: computed('person.title', 'person.firstName', 'person.lastName', function() {
|
|
2536
|
-
let { title, firstName, lastName } = this.person;
|
|
2537
|
-
|
|
2538
|
-
if (title) {
|
|
2539
|
-
return `${title} ${lastName}`;
|
|
2540
|
-
} else {
|
|
2541
|
-
return `${firstName} ${lastName}`;
|
|
2542
|
-
}
|
|
2543
|
-
})
|
|
2544
|
-
});
|
|
2545
|
-
```
|
|
2546
|
-
|
|
2547
|
-
And then use it in the component's template:
|
|
2548
|
-
|
|
2549
|
-
```app/templates/components/person-profile.hbs
|
|
2550
|
-
<h1>{{this.displayName}}</h1>
|
|
2551
|
-
{{yield}}
|
|
2552
|
-
```
|
|
2553
|
-
|
|
2554
|
-
## Customizing a Classic Component's HTML Element in JavaScript
|
|
2555
|
-
|
|
2556
|
-
### HTML Tag
|
|
2557
|
-
|
|
2558
|
-
The default HTML tag name used for a component's HTML representation is `div`.
|
|
2559
|
-
This can be customized by setting the `tagName` property.
|
|
2560
|
-
|
|
2561
|
-
Consider the following component class:
|
|
2562
|
-
|
|
2563
|
-
```app/components/emphasized-paragraph.js
|
|
2564
|
-
import Component from '@ember/component';
|
|
2565
|
-
|
|
2566
|
-
export default Component.extend({
|
|
2567
|
-
tagName: 'em'
|
|
2568
|
-
});
|
|
2569
|
-
```
|
|
2570
|
-
|
|
2571
|
-
When invoked, this component would produce output that looks something like
|
|
2572
|
-
this:
|
|
2573
|
-
|
|
2574
|
-
```html
|
|
2575
|
-
<em id="ember1" class="ember-view"></em>
|
|
2576
|
-
```
|
|
2577
|
-
|
|
2578
|
-
### HTML `class` Attribute
|
|
2579
|
-
|
|
2580
|
-
The HTML `class` attribute of a component's tag can be set by providing a
|
|
2581
|
-
`classNames` property that is set to an array of strings:
|
|
2582
|
-
|
|
2583
|
-
```app/components/my-widget.js
|
|
2584
|
-
import Component from '@ember/component';
|
|
2585
|
-
|
|
2586
|
-
export default Component.extend({
|
|
2587
|
-
classNames: ['my-class', 'my-other-class']
|
|
2588
|
-
});
|
|
2589
|
-
```
|
|
2590
|
-
|
|
2591
|
-
Invoking this component will produce output that looks like this:
|
|
2592
|
-
|
|
2593
|
-
```html
|
|
2594
|
-
<div id="ember1" class="ember-view my-class my-other-class"></div>
|
|
2595
|
-
```
|
|
2596
|
-
|
|
2597
|
-
`class` attribute values can also be set by providing a `classNameBindings`
|
|
2598
|
-
property set to an array of properties names for the component. The return
|
|
2599
|
-
value of these properties will be added as part of the value for the
|
|
2600
|
-
components's `class` attribute. These properties can be computed properties:
|
|
2601
|
-
|
|
2602
|
-
```app/components/my-widget.js
|
|
2603
|
-
import Component from '@ember/component';
|
|
2604
|
-
import { computed } from '@ember/object';
|
|
2605
|
-
|
|
2606
|
-
export default Component.extend({
|
|
2607
|
-
classNames: ['my-class', 'my-other-class'],
|
|
2608
|
-
classNameBindings: ['propertyA', 'propertyB'],
|
|
2609
|
-
|
|
2610
|
-
propertyA: 'from-a',
|
|
2611
|
-
propertyB: computed(function() {
|
|
2612
|
-
if (someLogic) { return 'from-b'; }
|
|
2613
|
-
})
|
|
2614
|
-
});
|
|
2615
|
-
```
|
|
2616
|
-
|
|
2617
|
-
Invoking this component will produce HTML that looks like:
|
|
2618
|
-
|
|
2619
|
-
```html
|
|
2620
|
-
<div id="ember1" class="ember-view my-class my-other-class from-a from-b"></div>
|
|
2621
|
-
```
|
|
2622
|
-
|
|
2623
|
-
Note that `classNames` and `classNameBindings` is in addition to the `class`
|
|
2624
|
-
attribute passed with the angle bracket invocation syntax. Therefore, if this
|
|
2625
|
-
component was invoked like so:
|
|
2626
|
-
|
|
2627
|
-
```handlebars
|
|
2628
|
-
<MyWidget class="from-invocation" />
|
|
2629
|
-
```
|
|
2630
|
-
|
|
2631
|
-
The resulting HTML will look similar to this:
|
|
2632
|
-
|
|
2633
|
-
```html
|
|
2634
|
-
<div id="ember1" class="from-invocation ember-view my-class my-other-class from-a from-b"></div>
|
|
2635
|
-
```
|
|
2636
|
-
|
|
2637
|
-
If the value of a class name binding returns a boolean the property name
|
|
2638
|
-
itself will be used as the class name if the property is true. The class name
|
|
2639
|
-
will not be added if the value is `false` or `undefined`.
|
|
2640
|
-
|
|
2641
|
-
```app/components/my-widget.js
|
|
2642
|
-
import Component from '@ember/component';
|
|
2643
|
-
|
|
2644
|
-
export default Component.extend({
|
|
2645
|
-
classNameBindings: ['hovered'],
|
|
2646
|
-
|
|
2647
|
-
hovered: true
|
|
2648
|
-
});
|
|
2649
|
-
```
|
|
2650
|
-
|
|
2651
|
-
Invoking this component will produce HTML that looks like:
|
|
2652
|
-
|
|
2653
|
-
```html
|
|
2654
|
-
<div id="ember1" class="ember-view hovered"></div>
|
|
2655
|
-
```
|
|
2656
|
-
|
|
2657
|
-
### Custom Class Names for Boolean Values
|
|
2658
|
-
|
|
2659
|
-
When using boolean class name bindings you can supply a string value other
|
|
2660
|
-
than the property name for use as the `class` HTML attribute by appending the
|
|
2661
|
-
preferred value after a ":" character when defining the binding:
|
|
2662
|
-
|
|
2663
|
-
```app/components/my-widget.js
|
|
2664
|
-
import Component from '@ember/component';
|
|
2665
|
-
|
|
2666
|
-
export default Component.extend({
|
|
2667
|
-
classNameBindings: ['awesome:so-very-cool'],
|
|
2668
|
-
|
|
2669
|
-
awesome: true
|
|
2670
|
-
});
|
|
2671
|
-
```
|
|
2672
|
-
|
|
2673
|
-
Invoking this component will produce HTML that looks like:
|
|
2674
|
-
|
|
2675
|
-
```html
|
|
2676
|
-
<div id="ember1" class="ember-view so-very-cool"></div>
|
|
2677
|
-
```
|
|
2678
|
-
|
|
2679
|
-
Boolean value class name bindings whose property names are in a
|
|
2680
|
-
camelCase-style format will be converted to a dasherized format:
|
|
2681
|
-
|
|
2682
|
-
```app/components/my-widget.js
|
|
2683
|
-
import Component from '@ember/component';
|
|
2684
|
-
|
|
2685
|
-
export default Component.extend({
|
|
2686
|
-
classNameBindings: ['isUrgent'],
|
|
2687
|
-
|
|
2688
|
-
isUrgent: true
|
|
2689
|
-
});
|
|
2690
|
-
```
|
|
2691
|
-
|
|
2692
|
-
Invoking this component will produce HTML that looks like:
|
|
2693
|
-
|
|
2694
|
-
```html
|
|
2695
|
-
<div id="ember1" class="ember-view is-urgent"></div>
|
|
2696
|
-
```
|
|
2697
|
-
|
|
2698
|
-
Class name bindings can also refer to object values that are found by
|
|
2699
|
-
traversing a path relative to the component itself:
|
|
2700
|
-
|
|
2701
|
-
```app/components/my-widget.js
|
|
2702
|
-
import Component from '@ember/component';
|
|
2703
|
-
import EmberObject from '@ember/object';
|
|
2704
|
-
|
|
2705
|
-
export default Component.extend({
|
|
2706
|
-
classNameBindings: ['messages.empty'],
|
|
2707
|
-
|
|
2708
|
-
messages: EmberObject.create({
|
|
2709
|
-
empty: true
|
|
2710
|
-
})
|
|
2711
|
-
});
|
|
2712
|
-
```
|
|
2713
|
-
|
|
2714
|
-
Invoking this component will produce HTML that looks like:
|
|
2715
|
-
|
|
2716
|
-
```html
|
|
2717
|
-
<div id="ember1" class="ember-view empty"></div>
|
|
2718
|
-
```
|
|
2719
|
-
|
|
2720
|
-
If you want to add a class name for a property which evaluates to true and
|
|
2721
|
-
and a different class name if it evaluates to false, you can pass a binding
|
|
2722
|
-
like this:
|
|
2723
|
-
|
|
2724
|
-
```app/components/my-widget.js
|
|
2725
|
-
import Component from '@ember/component';
|
|
2726
|
-
|
|
2727
|
-
export default Component.extend({
|
|
2728
|
-
classNameBindings: ['isEnabled:enabled:disabled'],
|
|
2729
|
-
isEnabled: true
|
|
2730
|
-
});
|
|
2731
|
-
```
|
|
2732
|
-
|
|
2733
|
-
Invoking this component will produce HTML that looks like:
|
|
2734
|
-
|
|
2735
|
-
```html
|
|
2736
|
-
<div id="ember1" class="ember-view enabled"></div>
|
|
2737
|
-
```
|
|
2738
|
-
|
|
2739
|
-
When isEnabled is `false`, the resulting HTML representation looks like this:
|
|
2740
|
-
|
|
2741
|
-
```html
|
|
2742
|
-
<div id="ember1" class="ember-view disabled"></div>
|
|
2743
|
-
```
|
|
2744
|
-
|
|
2745
|
-
This syntax offers the convenience to add a class if a property is `false`:
|
|
2746
|
-
|
|
2747
|
-
```app/components/my-widget.js
|
|
2748
|
-
import Component from '@ember/component';
|
|
2749
|
-
|
|
2750
|
-
// Applies no class when isEnabled is true and class 'disabled' when isEnabled is false
|
|
2751
|
-
export default Component.extend({
|
|
2752
|
-
classNameBindings: ['isEnabled::disabled'],
|
|
2753
|
-
isEnabled: true
|
|
2754
|
-
});
|
|
2755
|
-
```
|
|
2756
|
-
|
|
2757
|
-
Invoking this component when the `isEnabled` property is true will produce
|
|
2758
|
-
HTML that looks like:
|
|
2759
|
-
|
|
2760
|
-
```html
|
|
2761
|
-
<div id="ember1" class="ember-view"></div>
|
|
2762
|
-
```
|
|
2763
|
-
|
|
2764
|
-
Invoking it when the `isEnabled` property on the component is `false` will
|
|
2765
|
-
produce HTML that looks like:
|
|
2766
|
-
|
|
2767
|
-
```html
|
|
2768
|
-
<div id="ember1" class="ember-view disabled"></div>
|
|
2769
|
-
```
|
|
2770
|
-
|
|
2771
|
-
Updates to the value of a class name binding will result in automatic update
|
|
2772
|
-
of the HTML `class` attribute in the component's rendered HTML
|
|
2773
|
-
representation. If the value becomes `false` or `undefined` the class name
|
|
2774
|
-
will be removed.
|
|
2775
|
-
|
|
2776
|
-
Both `classNames` and `classNameBindings` are concatenated properties. See
|
|
2777
|
-
[EmberObject](/ember/release/classes/EmberObject) documentation for more
|
|
2778
|
-
information about concatenated properties.
|
|
2779
|
-
|
|
2780
|
-
### Other HTML Attributes
|
|
2781
|
-
|
|
2782
|
-
The HTML attribute section of a component's tag can be set by providing an
|
|
2783
|
-
`attributeBindings` property set to an array of property names on the component.
|
|
2784
|
-
The return value of these properties will be used as the value of the component's
|
|
2785
|
-
HTML associated attribute:
|
|
2786
|
-
|
|
2787
|
-
```app/components/my-anchor.js
|
|
2788
|
-
import Component from '@ember/component';
|
|
2789
|
-
|
|
2790
|
-
export default Component.extend({
|
|
2791
|
-
tagName: 'a',
|
|
2792
|
-
attributeBindings: ['href'],
|
|
2793
|
-
|
|
2794
|
-
href: 'http://google.com'
|
|
2795
|
-
});
|
|
2796
|
-
```
|
|
2797
|
-
|
|
2798
|
-
Invoking this component will produce HTML that looks like:
|
|
2799
|
-
|
|
2800
|
-
```html
|
|
2801
|
-
<a id="ember1" class="ember-view" href="http://google.com"></a>
|
|
2802
|
-
```
|
|
2803
|
-
|
|
2804
|
-
One property can be mapped on to another by placing a ":" between
|
|
2805
|
-
the source property and the destination property:
|
|
2806
|
-
|
|
2807
|
-
```app/components/my-anchor.js
|
|
2808
|
-
import Component from '@ember/component';
|
|
2809
|
-
|
|
2810
|
-
export default Component.extend({
|
|
2811
|
-
tagName: 'a',
|
|
2812
|
-
attributeBindings: ['url:href'],
|
|
2813
|
-
|
|
2814
|
-
url: 'http://google.com'
|
|
2815
|
-
});
|
|
2816
|
-
```
|
|
2817
|
-
|
|
2818
|
-
Invoking this component will produce HTML that looks like:
|
|
2819
|
-
|
|
2820
|
-
```html
|
|
2821
|
-
<a id="ember1" class="ember-view" href="http://google.com"></a>
|
|
2822
|
-
```
|
|
2823
|
-
|
|
2824
|
-
HTML attributes passed with angle bracket invocations will take precedence
|
|
2825
|
-
over those specified in `attributeBindings`. Therefore, if this component was
|
|
2826
|
-
invoked like so:
|
|
2827
|
-
|
|
2828
|
-
```handlebars
|
|
2829
|
-
<MyAnchor href="http://bing.com" @url="http://google.com" />
|
|
2830
|
-
```
|
|
2831
|
-
|
|
2832
|
-
The resulting HTML will looks like this:
|
|
2833
|
-
|
|
2834
|
-
```html
|
|
2835
|
-
<a id="ember1" class="ember-view" href="http://bing.com"></a>
|
|
2836
|
-
```
|
|
2837
|
-
|
|
2838
|
-
Note that the `href` attribute is ultimately set to `http://bing.com`,
|
|
2839
|
-
despite it having attribute binidng to the `url` property, which was
|
|
2840
|
-
set to `http://google.com`.
|
|
2841
|
-
|
|
2842
|
-
Namespaced attributes (e.g. `xlink:href`) are supported, but have to be
|
|
2843
|
-
mapped, since `:` is not a valid character for properties in Javascript:
|
|
2844
|
-
|
|
2845
|
-
```app/components/my-use.js
|
|
2846
|
-
import Component from '@ember/component';
|
|
2847
|
-
|
|
2848
|
-
export default Component.extend({
|
|
2849
|
-
tagName: 'use',
|
|
2850
|
-
attributeBindings: ['xlinkHref:xlink:href'],
|
|
2851
|
-
|
|
2852
|
-
xlinkHref: '#triangle'
|
|
2853
|
-
});
|
|
2854
|
-
```
|
|
2855
|
-
|
|
2856
|
-
Invoking this component will produce HTML that looks like:
|
|
2857
|
-
|
|
2858
|
-
```html
|
|
2859
|
-
<use xlink:href="#triangle"></use>
|
|
2860
|
-
```
|
|
2861
|
-
|
|
2862
|
-
If the value of a property monitored by `attributeBindings` is a boolean, the
|
|
2863
|
-
attribute will be present or absent depending on the value:
|
|
2864
|
-
|
|
2865
|
-
```app/components/my-text-input.js
|
|
2866
|
-
import Component from '@ember/component';
|
|
2867
|
-
|
|
2868
|
-
export default Component.extend({
|
|
2869
|
-
tagName: 'input',
|
|
2870
|
-
attributeBindings: ['disabled'],
|
|
2871
|
-
|
|
2872
|
-
disabled: false
|
|
2873
|
-
});
|
|
2874
|
-
```
|
|
2875
|
-
|
|
2876
|
-
Invoking this component will produce HTML that looks like:
|
|
2877
|
-
|
|
2878
|
-
```html
|
|
2879
|
-
<input id="ember1" class="ember-view" />
|
|
2880
|
-
```
|
|
2881
|
-
|
|
2882
|
-
`attributeBindings` can refer to computed properties:
|
|
2883
|
-
|
|
2884
|
-
```app/components/my-text-input.js
|
|
2885
|
-
import Component from '@ember/component';
|
|
2886
|
-
import { computed } from '@ember/object';
|
|
2887
|
-
|
|
2888
|
-
export default Component.extend({
|
|
2889
|
-
tagName: 'input',
|
|
2890
|
-
attributeBindings: ['disabled'],
|
|
2891
|
-
|
|
2892
|
-
disabled: computed(function() {
|
|
2893
|
-
if (someLogic) {
|
|
2894
|
-
return true;
|
|
2895
|
-
} else {
|
|
2896
|
-
return false;
|
|
2897
|
-
}
|
|
2898
|
-
})
|
|
2899
|
-
});
|
|
2900
|
-
```
|
|
2901
|
-
|
|
2902
|
-
To prevent setting an attribute altogether, use `null` or `undefined` as the
|
|
2903
|
-
value of the property used in `attributeBindings`:
|
|
2904
|
-
|
|
2905
|
-
```app/components/my-text-input.js
|
|
2906
|
-
import Component from '@ember/component';
|
|
2907
|
-
|
|
2908
|
-
export default Component.extend({
|
|
2909
|
-
tagName: 'form',
|
|
2910
|
-
attributeBindings: ['novalidate'],
|
|
2911
|
-
novalidate: null
|
|
2912
|
-
});
|
|
2913
|
-
```
|
|
2914
|
-
|
|
2915
|
-
Updates to the property of an attribute binding will result in automatic
|
|
2916
|
-
update of the HTML attribute in the component's HTML output.
|
|
2917
|
-
|
|
2918
|
-
`attributeBindings` is a concatenated property. See
|
|
2919
|
-
[EmberObject](/ember/release/classes/EmberObject) documentation for more
|
|
2920
|
-
information about concatenated properties.
|
|
2921
|
-
|
|
2922
|
-
## Layouts
|
|
2923
|
-
|
|
2924
|
-
The `layout` property can be used to dynamically specify a template associated
|
|
2925
|
-
with a component class, instead of relying on Ember to link together a
|
|
2926
|
-
component class and a template based on file names.
|
|
2927
|
-
|
|
2928
|
-
In general, applications should not use this feature, but it's commonly used
|
|
2929
|
-
in addons for historical reasons.
|
|
2930
|
-
|
|
2931
|
-
The `layout` property should be set to the default export of a template
|
|
2932
|
-
module, which is the name of a template file without the `.hbs` extension.
|
|
2933
|
-
|
|
2934
|
-
```app/templates/components/person-profile.hbs
|
|
2935
|
-
<h1>Person's Title</h1>
|
|
2936
|
-
<div class='details'>{{yield}}</div>
|
|
2937
|
-
```
|
|
2938
|
-
|
|
2939
|
-
```app/components/person-profile.js
|
|
2940
|
-
import Component from '@ember/component';
|
|
2941
|
-
import layout from '../templates/components/person-profile';
|
|
2942
|
-
|
|
2943
|
-
export default Component.extend({
|
|
2944
|
-
layout
|
|
2945
|
-
});
|
|
2946
|
-
```
|
|
2947
|
-
|
|
2948
|
-
If you invoke the component:
|
|
2949
|
-
|
|
2950
|
-
```handlebars
|
|
2951
|
-
<PersonProfile>
|
|
2952
|
-
<h2>Chief Basket Weaver</h2>
|
|
2953
|
-
<h3>Fisherman Industries</h3>
|
|
2954
|
-
</PersonProfile>
|
|
2955
|
-
```
|
|
2956
|
-
|
|
2957
|
-
or
|
|
2958
|
-
|
|
2959
|
-
```handlebars
|
|
2960
|
-
{{#person-profile}}
|
|
2961
|
-
<h2>Chief Basket Weaver</h2>
|
|
2962
|
-
<h3>Fisherman Industries</h3>
|
|
2963
|
-
{{/person-profile}}
|
|
2964
|
-
```
|
|
2965
|
-
|
|
2966
|
-
It will result in the following HTML output:
|
|
2967
|
-
|
|
2968
|
-
```html
|
|
2969
|
-
<h1>Person's Title</h1>
|
|
2970
|
-
<div class="details">
|
|
2971
|
-
<h2>Chief Basket Weaver</h2>
|
|
2972
|
-
<h3>Fisherman Industries</h3>
|
|
2973
|
-
</div>
|
|
2974
|
-
```
|
|
2975
|
-
|
|
2976
|
-
## Handling Browser Events
|
|
2977
|
-
|
|
2978
|
-
Components can respond to user-initiated events in one of three ways: passing
|
|
2979
|
-
actions with angle bracket invocation, adding event handler methods to the
|
|
2980
|
-
component's class, or adding actions to the component's template.
|
|
2981
|
-
|
|
2982
|
-
### Passing Actions With Angle Bracket Invocation
|
|
2983
|
-
|
|
2984
|
-
For one-off events specific to particular instance of a component, it is possible
|
|
2985
|
-
to pass actions to the component's element using angle bracket invocation syntax.
|
|
2986
|
-
|
|
2987
|
-
```handlebars
|
|
2988
|
-
<MyWidget {{action 'firstWidgetClicked'}} />
|
|
2989
|
-
|
|
2990
|
-
<MyWidget {{action 'secondWidgetClicked'}} />
|
|
2991
|
-
```
|
|
2992
|
-
|
|
2993
|
-
In this case, when the first component is clicked on, Ember will invoke the
|
|
2994
|
-
`firstWidgetClicked` action. When the second component is clicked on, Ember
|
|
2995
|
-
will invoke the `secondWidgetClicked` action instead.
|
|
2996
|
-
|
|
2997
|
-
Besides `{{action}}`, it is also possible to pass any arbitrary element modifiers
|
|
2998
|
-
using the angle bracket invocation syntax.
|
|
2999
|
-
|
|
3000
|
-
### Event Handler Methods
|
|
3001
|
-
|
|
3002
|
-
Components can also respond to user-initiated events by implementing a method
|
|
3003
|
-
that matches the event name. This approach is appropriate when the same event
|
|
3004
|
-
should be handled by all instances of the same component.
|
|
3005
|
-
|
|
3006
|
-
An event object will be passed as the argument to the event handler method.
|
|
3007
|
-
|
|
3008
|
-
```app/components/my-widget.js
|
|
3009
|
-
import Component from '@ember/component';
|
|
3010
|
-
|
|
3011
|
-
export default Component.extend({
|
|
3012
|
-
click(event) {
|
|
3013
|
-
// `event.target` is either the component's element or one of its children
|
|
3014
|
-
let tag = event.target.tagName.toLowerCase();
|
|
3015
|
-
console.log('clicked on a `<${tag}>` HTML element!');
|
|
3016
|
-
}
|
|
3017
|
-
});
|
|
3018
|
-
```
|
|
3019
|
-
|
|
3020
|
-
In this example, whenever the user clicked anywhere inside the component, it
|
|
3021
|
-
will log a message to the console.
|
|
3022
|
-
|
|
3023
|
-
It is possible to handle event types other than `click` by implementing the
|
|
3024
|
-
following event handler methods. In addition, custom events can be registered
|
|
3025
|
-
by using `Application.customEvents`.
|
|
3026
|
-
|
|
3027
|
-
Touch events:
|
|
3028
|
-
|
|
3029
|
-
* `touchStart`
|
|
3030
|
-
* `touchMove`
|
|
3031
|
-
* `touchEnd`
|
|
3032
|
-
* `touchCancel`
|
|
3033
|
-
|
|
3034
|
-
Keyboard events:
|
|
3035
|
-
|
|
3036
|
-
* `keyDown`
|
|
3037
|
-
* `keyUp`
|
|
3038
|
-
* `keyPress`
|
|
3039
|
-
|
|
3040
|
-
Mouse events:
|
|
3041
|
-
|
|
3042
|
-
* `mouseDown`
|
|
3043
|
-
* `mouseUp`
|
|
3044
|
-
* `contextMenu`
|
|
3045
|
-
* `click`
|
|
3046
|
-
* `doubleClick`
|
|
3047
|
-
* `focusIn`
|
|
3048
|
-
* `focusOut`
|
|
3049
|
-
|
|
3050
|
-
Form events:
|
|
3051
|
-
|
|
3052
|
-
* `submit`
|
|
3053
|
-
* `change`
|
|
3054
|
-
* `focusIn`
|
|
3055
|
-
* `focusOut`
|
|
3056
|
-
* `input`
|
|
3057
|
-
|
|
3058
|
-
Drag and drop events:
|
|
3059
|
-
|
|
3060
|
-
* `dragStart`
|
|
3061
|
-
* `drag`
|
|
3062
|
-
* `dragEnter`
|
|
3063
|
-
* `dragLeave`
|
|
3064
|
-
* `dragOver`
|
|
3065
|
-
* `dragEnd`
|
|
3066
|
-
* `drop`
|
|
3067
|
-
|
|
3068
|
-
### `{{action}}` Helper
|
|
3069
|
-
|
|
3070
|
-
Instead of handling all events of a particular type anywhere inside the
|
|
3071
|
-
component's element, you may instead want to limit it to a particular
|
|
3072
|
-
element in the component's template. In this case, it would be more
|
|
3073
|
-
convenient to implement an action instead.
|
|
3074
|
-
|
|
3075
|
-
For example, you could implement the action `hello` for the `person-profile`
|
|
3076
|
-
component:
|
|
3077
|
-
|
|
3078
|
-
```app/components/person-profile.js
|
|
3079
|
-
import Component from '@ember/component';
|
|
3080
|
-
|
|
3081
|
-
export default Component.extend({
|
|
3082
|
-
actions: {
|
|
3083
|
-
hello(name) {
|
|
3084
|
-
console.log("Hello", name);
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3087
|
-
});
|
|
3088
|
-
```
|
|
3089
|
-
|
|
3090
|
-
And then use it in the component's template:
|
|
3091
|
-
|
|
3092
|
-
```app/templates/components/person-profile.hbs
|
|
3093
|
-
<h1>{{@person.name}}</h1>
|
|
3094
|
-
|
|
3095
|
-
<button {{action 'hello' @person.name}}>
|
|
3096
|
-
Say Hello to {{@person.name}}
|
|
3097
|
-
</button>
|
|
3098
|
-
```
|
|
3099
|
-
|
|
3100
|
-
When the user clicks the button, Ember will invoke the `hello` action,
|
|
3101
|
-
passing in the current value of `@person.name` as an argument.
|
|
3102
|
-
|
|
3103
|
-
See [Ember.Templates.helpers.action](/ember/release/classes/Ember.Templates.helpers/methods/action?anchor=action).
|
|
3104
|
-
|
|
3105
|
-
@class Component
|
|
3106
|
-
@extends Ember.CoreView
|
|
3107
|
-
@uses Ember.TargetActionSupport
|
|
3108
|
-
@uses Ember.ClassNamesSupport
|
|
3109
|
-
@uses Ember.ActionSupport
|
|
3110
|
-
@uses Ember.ViewMixin
|
|
3111
|
-
@uses Ember.ViewStateSupport
|
|
3112
|
-
@public
|
|
3113
|
-
*/
|
|
3114
|
-
|
|
3115
2495
|
const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassNamesSupport, TargetActionSupport, ActionSupport, ViewMixin, {
|
|
3116
2496
|
isComponent: true,
|
|
3117
2497
|
|
|
@@ -3418,23 +2798,6 @@ const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassName
|
|
|
3418
2798
|
@since 1.13.0
|
|
3419
2799
|
*/
|
|
3420
2800
|
|
|
3421
|
-
/**
|
|
3422
|
-
Layout can be used to wrap content in a component.
|
|
3423
|
-
@property layout
|
|
3424
|
-
@type Function
|
|
3425
|
-
@public
|
|
3426
|
-
*/
|
|
3427
|
-
|
|
3428
|
-
/**
|
|
3429
|
-
The name of the layout to lookup if no layout is provided.
|
|
3430
|
-
By default `Component` will lookup a template with this name in
|
|
3431
|
-
`Ember.TEMPLATES` (a shared global object).
|
|
3432
|
-
@property layoutName
|
|
3433
|
-
@type String
|
|
3434
|
-
@default null
|
|
3435
|
-
@private
|
|
3436
|
-
*/
|
|
3437
|
-
|
|
3438
2801
|
/**
|
|
3439
2802
|
The HTML `id` of the component's element in the DOM. You can provide this
|
|
3440
2803
|
value yourself but it must be unique (just as in HTML):
|
|
@@ -4471,7 +3834,7 @@ setGlobalContext({
|
|
|
4471
3834
|
},
|
|
4472
3835
|
|
|
4473
3836
|
warnIfStyleNotTrusted(value) {
|
|
4474
|
-
warn(constructStyleDeprecationMessage(value), (() => {
|
|
3837
|
+
warn(constructStyleDeprecationMessage(String(value)), (() => {
|
|
4475
3838
|
if (value === null || value === undefined || isHTMLSafe$1(value)) {
|
|
4476
3839
|
return true;
|
|
4477
3840
|
}
|
|
@@ -4559,9 +3922,9 @@ var disallowDynamicResolution = internalHelper(({
|
|
|
4559
3922
|
}) => {
|
|
4560
3923
|
const nameOrValueRef = positional[0];
|
|
4561
3924
|
assert(`[BUG] wrong number of positional arguments, expecting 1, got ${positional.length}`, positional.length === 1 && nameOrValueRef);
|
|
4562
|
-
let typeRef = named
|
|
4563
|
-
let locRef = named
|
|
4564
|
-
let originalRef = named
|
|
3925
|
+
let typeRef = named['type'];
|
|
3926
|
+
let locRef = named['loc'];
|
|
3927
|
+
let originalRef = named['original'];
|
|
4565
3928
|
assert(`[BUG] expecting \`type\` named argument`, typeRef);
|
|
4566
3929
|
assert(`[BUG] expecting \`loc\` named argument`, locRef);
|
|
4567
3930
|
assert(`[BUG] expecting \`original\` named argument`, originalRef); // Bug: why do these fail?
|
|
@@ -4935,6 +4298,25 @@ var unbound = internalHelper(({
|
|
|
4935
4298
|
return createUnboundRef(valueForRef(positional[0]), '(result of an `unbound` helper)');
|
|
4936
4299
|
});
|
|
4937
4300
|
|
|
4301
|
+
/**
|
|
4302
|
+
@module ember
|
|
4303
|
+
*/
|
|
4304
|
+
var uniqueId = internalHelper(() => {
|
|
4305
|
+
return createConstRef(uniqueId$1(), 'unique-id');
|
|
4306
|
+
}); // From https://gist.github.com/selfish/fef2c0ba6cdfe07af76e64cecd74888b
|
|
4307
|
+
//
|
|
4308
|
+
// This code should be reasonably fast, and provide a unique value every time
|
|
4309
|
+
// it's called, which is what we need here. It produces a string formatted as a
|
|
4310
|
+
// standard UUID, which avoids accidentally turning Ember-specific
|
|
4311
|
+
// implementation details into an intimate API.
|
|
4312
|
+
|
|
4313
|
+
function uniqueId$1() {
|
|
4314
|
+
// @ts-expect-error this one-liner abuses weird JavaScript semantics that
|
|
4315
|
+
// TypeScript (legitimately) doesn't like, but they're nonetheless valid and
|
|
4316
|
+
// specced.
|
|
4317
|
+
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, a => (a ^ Math.random() * 16 >> a / 4).toString(16));
|
|
4318
|
+
}
|
|
4319
|
+
|
|
4938
4320
|
const MODIFIERS = ['alt', 'shift', 'meta', 'ctrl'];
|
|
4939
4321
|
const POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/;
|
|
4940
4322
|
|
|
@@ -5444,7 +4826,7 @@ const outletHelper = internalHelper((_args, owner, scope) => {
|
|
|
5444
4826
|
let outletRef = createComputeRef(() => {
|
|
5445
4827
|
let state = valueForRef(scope.get('outletState'));
|
|
5446
4828
|
let outlets = state !== undefined ? state.outlets : undefined;
|
|
5447
|
-
return outlets !== undefined ? outlets
|
|
4829
|
+
return outlets !== undefined ? outlets['main'] : undefined;
|
|
5448
4830
|
});
|
|
5449
4831
|
let lastState = null;
|
|
5450
4832
|
let definition = null;
|
|
@@ -5469,7 +4851,7 @@ const outletHelper = internalHelper((_args, owner, scope) => {
|
|
|
5469
4851
|
// provide the correct updated value. So we stop updating and return
|
|
5470
4852
|
// the _last_ model value for that outlet.
|
|
5471
4853
|
|
|
5472
|
-
named
|
|
4854
|
+
named['model'] = createComputeRef(() => {
|
|
5473
4855
|
if (lastState === state) {
|
|
5474
4856
|
model = valueForRef(modelRef);
|
|
5475
4857
|
}
|
|
@@ -5478,7 +4860,7 @@ const outletHelper = internalHelper((_args, owner, scope) => {
|
|
|
5478
4860
|
});
|
|
5479
4861
|
|
|
5480
4862
|
if (DEBUG) {
|
|
5481
|
-
named
|
|
4863
|
+
named['model'] = createDebugAliasRef('@model', named['model']);
|
|
5482
4864
|
}
|
|
5483
4865
|
|
|
5484
4866
|
let args = createCapturedArgs(named, EMPTY_POSITIONAL);
|
|
@@ -5606,6 +4988,11 @@ const BUILTIN_HELPERS = Object.assign(Object.assign({}, BUILTIN_KEYWORD_HELPERS)
|
|
|
5606
4988
|
get: get$1,
|
|
5607
4989
|
hash
|
|
5608
4990
|
});
|
|
4991
|
+
|
|
4992
|
+
{
|
|
4993
|
+
BUILTIN_HELPERS['unique-id'] = uniqueId;
|
|
4994
|
+
}
|
|
4995
|
+
|
|
5609
4996
|
const BUILTIN_KEYWORD_MODIFIERS = {
|
|
5610
4997
|
action: actionModifier
|
|
5611
4998
|
};
|
|
@@ -5758,6 +5145,104 @@ class ResolverImpl {
|
|
|
5758
5145
|
|
|
5759
5146
|
}
|
|
5760
5147
|
|
|
5148
|
+
const TOP_LEVEL_NAME = '-top-level';
|
|
5149
|
+
const TOP_LEVEL_OUTLET = 'main';
|
|
5150
|
+
class OutletView {
|
|
5151
|
+
constructor(_environment, owner, template, namespace) {
|
|
5152
|
+
this._environment = _environment;
|
|
5153
|
+
this.owner = owner;
|
|
5154
|
+
this.template = template;
|
|
5155
|
+
this.namespace = namespace;
|
|
5156
|
+
let outletStateTag = createTag();
|
|
5157
|
+
let outletState = {
|
|
5158
|
+
outlets: {
|
|
5159
|
+
main: undefined
|
|
5160
|
+
},
|
|
5161
|
+
render: {
|
|
5162
|
+
owner: owner,
|
|
5163
|
+
into: undefined,
|
|
5164
|
+
outlet: TOP_LEVEL_OUTLET,
|
|
5165
|
+
name: TOP_LEVEL_NAME,
|
|
5166
|
+
controller: undefined,
|
|
5167
|
+
model: undefined,
|
|
5168
|
+
template
|
|
5169
|
+
}
|
|
5170
|
+
};
|
|
5171
|
+
let ref = this.ref = createComputeRef(() => {
|
|
5172
|
+
consumeTag(outletStateTag);
|
|
5173
|
+
return outletState;
|
|
5174
|
+
}, state => {
|
|
5175
|
+
dirtyTag(outletStateTag);
|
|
5176
|
+
outletState.outlets['main'] = state;
|
|
5177
|
+
});
|
|
5178
|
+
this.state = {
|
|
5179
|
+
ref,
|
|
5180
|
+
name: TOP_LEVEL_NAME,
|
|
5181
|
+
outlet: TOP_LEVEL_OUTLET,
|
|
5182
|
+
template,
|
|
5183
|
+
controller: undefined,
|
|
5184
|
+
model: undefined
|
|
5185
|
+
};
|
|
5186
|
+
}
|
|
5187
|
+
|
|
5188
|
+
static extend(injections) {
|
|
5189
|
+
return class extends OutletView {
|
|
5190
|
+
static create(options) {
|
|
5191
|
+
if (options) {
|
|
5192
|
+
return super.create(Object.assign({}, injections, options));
|
|
5193
|
+
} else {
|
|
5194
|
+
return super.create(injections);
|
|
5195
|
+
}
|
|
5196
|
+
}
|
|
5197
|
+
|
|
5198
|
+
};
|
|
5199
|
+
}
|
|
5200
|
+
|
|
5201
|
+
static reopenClass(injections) {
|
|
5202
|
+
Object.assign(this, injections);
|
|
5203
|
+
}
|
|
5204
|
+
|
|
5205
|
+
static create(options) {
|
|
5206
|
+
let {
|
|
5207
|
+
environment: _environment,
|
|
5208
|
+
application: namespace,
|
|
5209
|
+
template: templateFactory$$1
|
|
5210
|
+
} = options;
|
|
5211
|
+
let owner = getOwner(options);
|
|
5212
|
+
assert('OutletView is unexpectedly missing an owner', owner);
|
|
5213
|
+
let template = templateFactory$$1(owner);
|
|
5214
|
+
return new OutletView(_environment, owner, template, namespace);
|
|
5215
|
+
}
|
|
5216
|
+
|
|
5217
|
+
appendTo(selector) {
|
|
5218
|
+
let target;
|
|
5219
|
+
|
|
5220
|
+
if (this._environment.hasDOM) {
|
|
5221
|
+
target = typeof selector === 'string' ? document.querySelector(selector) : selector;
|
|
5222
|
+
} else {
|
|
5223
|
+
target = selector;
|
|
5224
|
+
}
|
|
5225
|
+
|
|
5226
|
+
let renderer = this.owner.lookup('renderer:-dom'); // SAFETY: It's not clear that this cast is safe.
|
|
5227
|
+
// The types for appendOutletView may be incorrect or this is a potential bug.
|
|
5228
|
+
|
|
5229
|
+
schedule('render', renderer, 'appendOutletView', this, target);
|
|
5230
|
+
}
|
|
5231
|
+
|
|
5232
|
+
rerender() {
|
|
5233
|
+
/**/
|
|
5234
|
+
}
|
|
5235
|
+
|
|
5236
|
+
setOutletState(state) {
|
|
5237
|
+
updateRef(this.ref, state);
|
|
5238
|
+
}
|
|
5239
|
+
|
|
5240
|
+
destroy() {
|
|
5241
|
+
/**/
|
|
5242
|
+
}
|
|
5243
|
+
|
|
5244
|
+
}
|
|
5245
|
+
|
|
5761
5246
|
class DynamicScope {
|
|
5762
5247
|
constructor(view, outletState) {
|
|
5763
5248
|
this.view = view;
|
|
@@ -5812,7 +5297,7 @@ class RootState {
|
|
|
5812
5297
|
this.root = root;
|
|
5813
5298
|
this.runtime = runtime;
|
|
5814
5299
|
assert(`You cannot render \`${valueForRef(self)}\` without a template.`, template !== undefined);
|
|
5815
|
-
this.id = getViewId(root);
|
|
5300
|
+
this.id = root instanceof OutletView ? guidFor(root) : getViewId(root);
|
|
5816
5301
|
this.result = undefined;
|
|
5817
5302
|
this.destroyed = false;
|
|
5818
5303
|
this.render = errorLoopTransaction(() => {
|
|
@@ -6244,102 +5729,6 @@ var OutletTemplate = templateFactory({
|
|
|
6244
5729
|
"isStrictMode": false
|
|
6245
5730
|
});
|
|
6246
5731
|
|
|
6247
|
-
const TOP_LEVEL_NAME = '-top-level';
|
|
6248
|
-
const TOP_LEVEL_OUTLET = 'main';
|
|
6249
|
-
class OutletView {
|
|
6250
|
-
constructor(_environment, owner, template, namespace) {
|
|
6251
|
-
this._environment = _environment;
|
|
6252
|
-
this.owner = owner;
|
|
6253
|
-
this.template = template;
|
|
6254
|
-
this.namespace = namespace;
|
|
6255
|
-
let outletStateTag = createTag();
|
|
6256
|
-
let outletState = {
|
|
6257
|
-
outlets: {
|
|
6258
|
-
main: undefined
|
|
6259
|
-
},
|
|
6260
|
-
render: {
|
|
6261
|
-
owner: owner,
|
|
6262
|
-
into: undefined,
|
|
6263
|
-
outlet: TOP_LEVEL_OUTLET,
|
|
6264
|
-
name: TOP_LEVEL_NAME,
|
|
6265
|
-
controller: undefined,
|
|
6266
|
-
model: undefined,
|
|
6267
|
-
template
|
|
6268
|
-
}
|
|
6269
|
-
};
|
|
6270
|
-
let ref = this.ref = createComputeRef(() => {
|
|
6271
|
-
consumeTag(outletStateTag);
|
|
6272
|
-
return outletState;
|
|
6273
|
-
}, state => {
|
|
6274
|
-
dirtyTag(outletStateTag);
|
|
6275
|
-
outletState.outlets.main = state;
|
|
6276
|
-
});
|
|
6277
|
-
this.state = {
|
|
6278
|
-
ref,
|
|
6279
|
-
name: TOP_LEVEL_NAME,
|
|
6280
|
-
outlet: TOP_LEVEL_OUTLET,
|
|
6281
|
-
template,
|
|
6282
|
-
controller: undefined,
|
|
6283
|
-
model: undefined
|
|
6284
|
-
};
|
|
6285
|
-
}
|
|
6286
|
-
|
|
6287
|
-
static extend(injections) {
|
|
6288
|
-
return class extends OutletView {
|
|
6289
|
-
static create(options) {
|
|
6290
|
-
if (options) {
|
|
6291
|
-
return super.create(Object.assign({}, injections, options));
|
|
6292
|
-
} else {
|
|
6293
|
-
return super.create(injections);
|
|
6294
|
-
}
|
|
6295
|
-
}
|
|
6296
|
-
|
|
6297
|
-
};
|
|
6298
|
-
}
|
|
6299
|
-
|
|
6300
|
-
static reopenClass(injections) {
|
|
6301
|
-
Object.assign(this, injections);
|
|
6302
|
-
}
|
|
6303
|
-
|
|
6304
|
-
static create(options) {
|
|
6305
|
-
let {
|
|
6306
|
-
environment: _environment,
|
|
6307
|
-
application: namespace,
|
|
6308
|
-
template: templateFactory$$1
|
|
6309
|
-
} = options;
|
|
6310
|
-
let owner = getOwner(options);
|
|
6311
|
-
assert('OutletView is unexpectedly missing an owner', owner);
|
|
6312
|
-
let template = templateFactory$$1(owner);
|
|
6313
|
-
return new OutletView(_environment, owner, template, namespace);
|
|
6314
|
-
}
|
|
6315
|
-
|
|
6316
|
-
appendTo(selector) {
|
|
6317
|
-
let target;
|
|
6318
|
-
|
|
6319
|
-
if (this._environment.hasDOM) {
|
|
6320
|
-
target = typeof selector === 'string' ? document.querySelector(selector) : selector;
|
|
6321
|
-
} else {
|
|
6322
|
-
target = selector;
|
|
6323
|
-
}
|
|
6324
|
-
|
|
6325
|
-
let renderer = this.owner.lookup('renderer:-dom');
|
|
6326
|
-
schedule('render', renderer, 'appendOutletView', this, target);
|
|
6327
|
-
}
|
|
6328
|
-
|
|
6329
|
-
rerender() {
|
|
6330
|
-
/**/
|
|
6331
|
-
}
|
|
6332
|
-
|
|
6333
|
-
setOutletState(state) {
|
|
6334
|
-
updateRef(this.ref, state);
|
|
6335
|
-
}
|
|
6336
|
-
|
|
6337
|
-
destroy() {
|
|
6338
|
-
/**/
|
|
6339
|
-
}
|
|
6340
|
-
|
|
6341
|
-
}
|
|
6342
|
-
|
|
6343
5732
|
function setupApplicationRegistry(registry) {
|
|
6344
5733
|
// because we are using injections we can't use instantiate false
|
|
6345
5734
|
// we need to use bind() to copy the function so factory for
|
|
@@ -6384,6 +5773,18 @@ function setupEngineRegistry(registry) {
|
|
|
6384
5773
|
}
|
|
6385
5774
|
}
|
|
6386
5775
|
|
|
5776
|
+
/**
|
|
5777
|
+
Associate a class with a component manager (an object that is responsible for
|
|
5778
|
+
coordinating the lifecycle events that occurs when invoking, rendering and
|
|
5779
|
+
re-rendering a component).
|
|
5780
|
+
|
|
5781
|
+
@method setComponentManager
|
|
5782
|
+
@param {Function} factory a function to create the owner for an object
|
|
5783
|
+
@param {Object} obj the object to associate with the componetn manager
|
|
5784
|
+
@return {Object} the same object passed in
|
|
5785
|
+
@public
|
|
5786
|
+
*/
|
|
5787
|
+
|
|
6387
5788
|
function setComponentManager$1(manager, obj) {
|
|
6388
5789
|
return setComponentManager(manager, obj);
|
|
6389
5790
|
}
|