ember-source 4.4.0-alpha.6 → 4.4.0-alpha.7

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.
@@ -5,5 +5,5 @@
5
5
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
6
  * @license Licensed under MIT license
7
7
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
- * @version 4.4.0-alpha.6
8
+ * @version 4.4.0-alpha.7
9
9
  */
@@ -396,7 +396,6 @@ class FactoryManager {
396
396
  this.normalizedName = normalizedName;
397
397
  this.madeToString = undefined;
398
398
  this.injections = undefined;
399
- setFactoryFor(this, this);
400
399
  }
401
400
 
402
401
  toString() {
@@ -2492,16 +2492,40 @@ function isCurlyManager(manager) {
2492
2492
  }
2493
2493
 
2494
2494
  let lazyEventsProcessed = new WeakMap();
2495
- const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassNamesSupport, TargetActionSupport, ActionSupport, ViewMixin, {
2496
- isComponent: true,
2497
2495
 
2498
- init() {
2499
- this._super(...arguments);
2496
+ class Component extends CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassNamesSupport, TargetActionSupport, ActionSupport, ViewMixin, {
2497
+ // These need to be overridable via extend/create but should still
2498
+ // have a default. Defining them here is the best way to achieve that.
2499
+ didReceiveAttrs() {},
2500
+
2501
+ didRender() {},
2502
+
2503
+ didUpdate() {},
2504
+
2505
+ didUpdateAttrs() {},
2506
+
2507
+ willRender() {},
2508
+
2509
+ willUpdate() {}
2510
+
2511
+ }) {
2512
+ constructor() {
2513
+ super(...arguments);
2514
+ this.isComponent = true;
2515
+ }
2516
+
2517
+ init(properties) {
2518
+ super.init(properties); // Handle methods from ViewMixin.
2519
+ // The native class inheritance will not work for mixins. To work around this,
2520
+ // we copy the existing rerender method provided by the mixin and swap in the
2521
+ // new rerender method from our class.
2500
2522
 
2523
+ this._superRerender = this.rerender;
2524
+ this.rerender = this._rerender;
2501
2525
  this[IS_DISPATCHING_ATTRS] = false;
2502
2526
  this[DIRTY_TAG] = createTag();
2503
2527
  this[BOUNDS] = null;
2504
- let eventDispatcher = this._dispatcher;
2528
+ const eventDispatcher = this._dispatcher;
2505
2529
 
2506
2530
  if (eventDispatcher) {
2507
2531
  let lazyEventsProcessedForComponentClass = lazyEventsProcessed.get(eventDispatcher);
@@ -2531,7 +2555,7 @@ const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassName
2531
2555
  for (let key in events) {
2532
2556
  let methodName = events[key];
2533
2557
 
2534
- if (typeof this[methodName] === 'function') {
2558
+ if (methodName && typeof this[methodName] === 'function') {
2535
2559
  eventNames.push(methodName);
2536
2560
  }
2537
2561
  } // If in a tagless component, assert that no event handlers are defined
@@ -2539,7 +2563,7 @@ const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassName
2539
2563
 
2540
2564
  assert(`You can not define \`${eventNames}\` function(s) to handle DOM event in the \`${this}\` tagless component since it doesn't have any DOM element.`, !eventNames.length);
2541
2565
  }
2542
- },
2566
+ }
2543
2567
 
2544
2568
  get _dispatcher() {
2545
2569
  if (this.__dispatcher === undefined) {
@@ -2547,8 +2571,9 @@ const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassName
2547
2571
  assert('Component is unexpectedly missing an owner', owner);
2548
2572
 
2549
2573
  if (owner.lookup('-environment:main').isInteractive) {
2550
- this.__dispatcher = owner.lookup('event_dispatcher:main');
2551
- assert('Expected dispatcher to be an EventDispatcher', this.__dispatcher instanceof EventDispatcher);
2574
+ let dispatcher = owner.lookup('event_dispatcher:main');
2575
+ assert('Expected dispatcher to be an EventDispatcher', dispatcher instanceof EventDispatcher);
2576
+ this.__dispatcher = dispatcher;
2552
2577
  } else {
2553
2578
  // In FastBoot we have no EventDispatcher. Set to null to not try again to look it up.
2554
2579
  this.__dispatcher = null;
@@ -2556,20 +2581,24 @@ const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassName
2556
2581
  }
2557
2582
 
2558
2583
  return this.__dispatcher;
2559
- },
2584
+ }
2560
2585
 
2561
- on(eventName) {
2586
+ on(name, target, method) {
2562
2587
  var _a;
2563
2588
 
2564
- (_a = this._dispatcher) === null || _a === void 0 ? void 0 : _a.setupHandlerForEmberEvent(eventName);
2565
- return this._super(...arguments);
2566
- },
2589
+ (_a = this._dispatcher) === null || _a === void 0 ? void 0 : _a.setupHandlerForEmberEvent(name); // The `on` method here comes from the Evented mixin. Since this mixin
2590
+ // is applied to the parent of this class, however, we are still able
2591
+ // to use `super`.
2567
2592
 
2568
- rerender() {
2593
+ return super.on(name, target, method);
2594
+ } // Changed to `rerender` on init
2595
+
2596
+
2597
+ _rerender() {
2569
2598
  dirtyTag(this[DIRTY_TAG]);
2570
2599
 
2571
- this._super();
2572
- },
2600
+ this._superRerender();
2601
+ }
2573
2602
 
2574
2603
  [PROPERTY_DID_CHANGE](key, value) {
2575
2604
  if (this[IS_DISPATCHING_ATTRS]) {
@@ -2582,39 +2611,40 @@ const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassName
2582
2611
  if (reference !== undefined && isUpdatableRef(reference)) {
2583
2612
  updateRef(reference, arguments.length === 2 ? value : get(this, key));
2584
2613
  }
2585
- },
2614
+ }
2586
2615
 
2587
2616
  getAttr(key) {
2588
2617
  // TODO Intimate API should be deprecated
2589
2618
  return this.get(key);
2590
- },
2591
-
2619
+ }
2592
2620
  /**
2593
2621
  Normally, Ember's component model is "write-only". The component takes a
2594
2622
  bunch of attributes that it got passed in, and uses them to render its
2595
2623
  template.
2596
- One nice thing about this model is that if you try to set a value to the
2624
+ One nice thing about this model is that if you try to set a value to the
2597
2625
  same thing as last time, Ember (through HTMLBars) will avoid doing any
2598
2626
  work on the DOM.
2599
- This is not just a performance optimization. If an attribute has not
2627
+ This is not just a performance optimization. If an attribute has not
2600
2628
  changed, it is important not to clobber the element's "hidden state".
2601
2629
  For example, if you set an input's `value` to the same value as before,
2602
2630
  it will clobber selection state and cursor position. In other words,
2603
2631
  setting an attribute is not **always** idempotent.
2604
- This method provides a way to read an element's attribute and also
2632
+ This method provides a way to read an element's attribute and also
2605
2633
  update the last value Ember knows about at the same time. This makes
2606
2634
  setting an attribute idempotent.
2607
- In particular, what this means is that if you get an `<input>` element's
2635
+ In particular, what this means is that if you get an `<input>` element's
2608
2636
  `value` attribute and then re-render the template with the same value,
2609
2637
  it will avoid clobbering the cursor and selection position.
2610
2638
  Since most attribute sets are idempotent in the browser, you typically
2611
2639
  can get away with reading attributes using jQuery, but the most reliable
2612
2640
  way to do so is through this method.
2613
2641
  @method readDOMAttr
2614
- @param {String} name the name of the attribute
2642
+ @param {String} name the name of the attribute
2615
2643
  @return String
2616
2644
  @public
2617
- */
2645
+ */
2646
+
2647
+
2618
2648
  readDOMAttr(name) {
2619
2649
  // TODO revisit this
2620
2650
  let _element = getViewElement(this);
@@ -2634,205 +2664,60 @@ const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassName
2634
2664
  }
2635
2665
 
2636
2666
  return element[normalized];
2637
- },
2638
-
2639
- /**
2640
- The WAI-ARIA role of the control represented by this view. For example, a
2641
- button may have a role of type 'button', or a pane may have a role of
2642
- type 'alertdialog'. This property is used by assistive software to help
2643
- visually challenged users navigate rich web applications.
2644
- The full list of valid WAI-ARIA roles is available at:
2645
- [https://www.w3.org/TR/wai-aria/#roles_categorization](https://www.w3.org/TR/wai-aria/#roles_categorization)
2646
- @property ariaRole
2647
- @type String
2648
- @default null
2649
- @public
2650
- */
2651
-
2652
- /**
2653
- Enables components to take a list of parameters as arguments.
2654
- For example, a component that takes two parameters with the names
2655
- `name` and `age`:
2656
- ```app/components/my-component.js
2657
- import Component from '@ember/component';
2658
- let MyComponent = Component.extend();
2659
- MyComponent.reopenClass({
2660
- positionalParams: ['name', 'age']
2661
- });
2662
- export default MyComponent;
2663
- ```
2664
- It can then be invoked like this:
2665
- ```hbs
2666
- {{my-component "John" 38}}
2667
- ```
2668
- The parameters can be referred to just like named parameters:
2669
- ```hbs
2670
- Name: {{name}}, Age: {{age}}.
2671
- ```
2672
- Using a string instead of an array allows for an arbitrary number of
2673
- parameters:
2674
- ```app/components/my-component.js
2675
- import Component from '@ember/component';
2676
- let MyComponent = Component.extend();
2677
- MyComponent.reopenClass({
2678
- positionalParams: 'names'
2679
- });
2680
- export default MyComponent;
2681
- ```
2682
- It can then be invoked like this:
2683
- ```hbs
2684
- {{my-component "John" "Michael" "Scott"}}
2685
- ```
2686
- The parameters can then be referred to by enumerating over the list:
2687
- ```hbs
2688
- {{#each names as |name|}}{{name}}{{/each}}
2689
- ```
2690
- @static
2691
- @public
2692
- @property positionalParams
2693
- @since 1.13.0
2694
- */
2695
-
2696
- /**
2697
- Called when the attributes passed into the component have been updated.
2698
- Called both during the initial render of a container and during a rerender.
2699
- Can be used in place of an observer; code placed here will be executed
2700
- every time any attribute updates.
2701
- @method didReceiveAttrs
2702
- @public
2703
- @since 1.13.0
2704
- */
2705
- didReceiveAttrs() {},
2706
-
2707
- /**
2708
- Called when the attributes passed into the component have been updated.
2709
- Called both during the initial render of a container and during a rerender.
2710
- Can be used in place of an observer; code placed here will be executed
2711
- every time any attribute updates.
2712
- @event didReceiveAttrs
2713
- @public
2714
- @since 1.13.0
2715
- */
2716
-
2717
- /**
2718
- Called after a component has been rendered, both on initial render and
2719
- in subsequent rerenders.
2720
- @method didRender
2721
- @public
2722
- @since 1.13.0
2723
- */
2724
- didRender() {},
2725
-
2726
- /**
2727
- Called after a component has been rendered, both on initial render and
2728
- in subsequent rerenders.
2729
- @event didRender
2730
- @public
2731
- @since 1.13.0
2732
- */
2733
-
2734
- /**
2735
- Called before a component has been rendered, both on initial render and
2736
- in subsequent rerenders.
2737
- @method willRender
2738
- @public
2739
- @since 1.13.0
2740
- */
2741
- willRender() {},
2742
-
2743
- /**
2744
- Called before a component has been rendered, both on initial render and
2745
- in subsequent rerenders.
2746
- @event willRender
2747
- @public
2748
- @since 1.13.0
2749
- */
2750
-
2751
- /**
2752
- Called when the attributes passed into the component have been changed.
2753
- Called only during a rerender, not during an initial render.
2754
- @method didUpdateAttrs
2755
- @public
2756
- @since 1.13.0
2757
- */
2758
- didUpdateAttrs() {},
2759
-
2760
- /**
2761
- Called when the attributes passed into the component have been changed.
2762
- Called only during a rerender, not during an initial render.
2763
- @event didUpdateAttrs
2764
- @public
2765
- @since 1.13.0
2766
- */
2667
+ }
2767
2668
 
2768
- /**
2769
- Called when the component is about to update and rerender itself.
2770
- Called only during a rerender, not during an initial render.
2771
- @method willUpdate
2772
- @public
2773
- @since 1.13.0
2774
- */
2775
- willUpdate() {},
2669
+ static toString() {
2670
+ return '@ember/component';
2671
+ }
2776
2672
 
2777
- /**
2778
- Called when the component is about to update and rerender itself.
2779
- Called only during a rerender, not during an initial render.
2780
- @event willUpdate
2781
- @public
2782
- @since 1.13.0
2783
- */
2673
+ }
2784
2674
 
2785
- /**
2786
- Called when the component has updated and rerendered itself.
2787
- Called only during a rerender, not during an initial render.
2788
- @method didUpdate
2789
- @public
2790
- @since 1.13.0
2791
- */
2792
- didUpdate() {}
2793
- /**
2794
- Called when the component has updated and rerendered itself.
2795
- Called only during a rerender, not during an initial render.
2796
- @event didUpdate
2797
- @public
2798
- @since 1.13.0
2799
- */
2675
+ Component.isComponentFactory = true; // We continue to use reopenClass here so that positionalParams can be overridden with reopenClass in subclasses.
2800
2676
 
2677
+ Component.reopenClass({
2801
2678
  /**
2802
- The HTML `id` of the component's element in the DOM. You can provide this
2803
- value yourself but it must be unique (just as in HTML):
2804
- ```handlebars
2805
- {{my-component elementId="a-really-cool-id"}}
2679
+ Enables components to take a list of parameters as arguments.
2680
+ For example, a component that takes two parameters with the names
2681
+ `name` and `age`:
2682
+ ```app/components/my-component.js
2683
+ import Component from '@ember/component';
2684
+ let MyComponent = Component.extend();
2685
+ MyComponent.reopenClass({
2686
+ positionalParams: ['name', 'age']
2687
+ });
2688
+ export default MyComponent;
2806
2689
  ```
2807
- ```handlebars
2808
- <MyComponent @elementId="a-really-cool-id" />
2690
+ It can then be invoked like this:
2691
+ ```hbs
2692
+ {{my-component "John" 38}}
2809
2693
  ```
2810
- If not manually set a default value will be provided by the framework.
2811
- Once rendered an element's `elementId` is considered immutable and you
2812
- should never change it. If you need to compute a dynamic value for the
2813
- `elementId`, you should do this when the component or element is being
2814
- instantiated:
2815
- ```javascript
2816
- export default Component.extend({
2817
- init() {
2818
- this._super(...arguments);
2819
- var index = this.get('index');
2820
- this.set('elementId', `component-id${index}`);
2821
- }
2694
+ The parameters can be referred to just like named parameters:
2695
+ ```hbs
2696
+ Name: {{name}}, Age: {{age}}.
2697
+ ```
2698
+ Using a string instead of an array allows for an arbitrary number of
2699
+ parameters:
2700
+ ```app/components/my-component.js
2701
+ import Component from '@ember/component';
2702
+ let MyComponent = Component.extend();
2703
+ MyComponent.reopenClass({
2704
+ positionalParams: 'names'
2822
2705
  });
2706
+ export default MyComponent;
2707
+ ```
2708
+ It can then be invoked like this:
2709
+ ```hbs
2710
+ {{my-component "John" "Michael" "Scott"}}
2823
2711
  ```
2824
- @property elementId
2825
- @type String
2712
+ The parameters can then be referred to by enumerating over the list:
2713
+ ```hbs
2714
+ {{#each names as |name|}}{{name}}{{/each}}
2715
+ ```
2716
+ @static
2826
2717
  @public
2827
- */
2828
-
2829
-
2830
- });
2831
-
2832
- Component.toString = () => '@ember/component';
2833
-
2834
- Component.reopenClass({
2835
- isComponentFactory: true,
2718
+ @property positionalParams
2719
+ @since 1.13.0
2720
+ */
2836
2721
  positionalParams: []
2837
2722
  });
2838
2723
  setInternalComponentManager(CURLY_COMPONENT_MANAGER, Component);
@@ -2845,8 +2730,8 @@ const RECOMPUTE_TAG = symbol('RECOMPUTE_TAG');
2845
2730
  const IS_CLASSIC_HELPER = Symbol('IS_CLASSIC_HELPER');
2846
2731
 
2847
2732
  class Helper extends FrameworkObject {
2848
- init() {
2849
- super.init();
2733
+ init(properties) {
2734
+ super.init(properties);
2850
2735
  this[RECOMPUTE_TAG] = createTag();
2851
2736
  }
2852
2737
  /**
@@ -367,7 +367,7 @@ export class Meta {
367
367
  ) {
368
368
  listeners.splice(i, 1);
369
369
  } else {
370
- assert(`You attempted to add an observer for the same method on '${event.split(':')[0]}' twice to ${target} as both sync and async. Observers must be either sync or async, they cannot be both. This is likely a mistake, you should either remove the code that added the observer a second time, or update it to always be sync or async. The method was ${method}.`, !(listener.kind === 0
370
+ assert(`You attempted to add an observer for the same method on '${event.split(':')[0]}' twice to ${target} as both sync and async. Observers must be either sync or async, they cannot be both. This is likely a mistake, you should either remove the code that added the observer a second time, or update it to always be sync or async. The method was ${String(method)}.`, !(listener.kind === 0
371
371
  /* ADD */
372
372
  && kind === 0
373
373
  /* ADD */
@@ -1771,6 +1771,9 @@ if (DEBUG) {
1771
1771
  };
1772
1772
  }
1773
1773
 
1774
+ function hasUnknownProperty(val) {
1775
+ return typeof val === 'object' && val !== null && typeof val.unknownProperty === 'function';
1776
+ }
1774
1777
  function get(obj, keyName) {
1775
1778
  assert(`Get must be called with two arguments; an object and a property key`, arguments.length === 2);
1776
1779
  assert(`Cannot call get with '${keyName}' on an undefined object.`, obj !== undefined && obj !== null);
@@ -1792,7 +1795,7 @@ function _getProp(obj, keyName) {
1792
1795
  value = obj[keyName];
1793
1796
  }
1794
1797
 
1795
- if (value === undefined && typeof obj === 'object' && !(keyName in obj) && typeof obj.unknownProperty === 'function') {
1798
+ if (value === undefined && typeof obj === 'object' && !(keyName in obj) && hasUnknownProperty(obj)) {
1796
1799
  value = obj.unknownProperty(keyName);
1797
1800
  }
1798
1801
 
@@ -2182,7 +2185,7 @@ function isEmpty(obj) {
2182
2185
  return true;
2183
2186
  }
2184
2187
 
2185
- if (typeof obj.unknownProperty !== 'function' && typeof obj.size === 'number') {
2188
+ if (!hasUnknownProperty(obj) && typeof obj.size === 'number') {
2186
2189
  return !obj.size;
2187
2190
  }
2188
2191
 
@@ -3576,4 +3579,4 @@ function throwCachedInvalidArgsError(args = []) {
3576
3579
  @public
3577
3580
  */
3578
3581
 
3579
- export { computed, autoComputed, isComputed, ComputedProperty, getCachedValueFor, alias, deprecateProperty, PROXY_CONTENT, _getPath, get, _getProp, set, _setProp, trySet, objectAt, replace, replaceInNativeArray, addArrayObserver, removeArrayObserver, arrayContentWillChange, arrayContentDidChange, eachProxyArrayWillChange, eachProxyArrayDidChange, addListener, hasListeners, on, removeListener, sendEvent, isNone, isEmpty, isBlank, isPresent, beginPropertyChanges, changeProperties, endPropertyChanges, notifyPropertyChange, PROPERTY_DID_CHANGE, defineProperty, isElementDescriptor, nativeDescDecorator, descriptorForDecorator, descriptorForProperty, isClassicDecorator, setClassicDecorator, LIBRARIES as libraries, Libraries, getProperties, setProperties, expandProperties, ASYNC_OBSERVERS, SYNC_OBSERVERS, addObserver, activateObserver, removeObserver, flushAsyncObservers, Mixin, mixin, observer, applyMixin, inject, DEBUG_INJECTION_FUNCTIONS, tagForProperty, tagForObject, markObjectAsDirty, tracked, TrackedDescriptor, cached, NAMESPACES, NAMESPACES_BY_ID, addNamespace, findNamespace, findNamespaces, processNamespace, processAllNamespaces, removeNamespace, isSearchDisabled as isNamespaceSearchDisabled, setSearchDisabled as setNamespaceSearchDisabled };
3582
+ export { computed, autoComputed, isComputed, ComputedProperty, getCachedValueFor, alias, deprecateProperty, PROXY_CONTENT, _getPath, get, _getProp, hasUnknownProperty, set, _setProp, trySet, objectAt, replace, replaceInNativeArray, addArrayObserver, removeArrayObserver, arrayContentWillChange, arrayContentDidChange, eachProxyArrayWillChange, eachProxyArrayDidChange, addListener, hasListeners, on, removeListener, sendEvent, isNone, isEmpty, isBlank, isPresent, beginPropertyChanges, changeProperties, endPropertyChanges, notifyPropertyChange, PROPERTY_DID_CHANGE, defineProperty, isElementDescriptor, nativeDescDecorator, descriptorForDecorator, descriptorForProperty, isClassicDecorator, setClassicDecorator, LIBRARIES as libraries, Libraries, getProperties, setProperties, expandProperties, ASYNC_OBSERVERS, SYNC_OBSERVERS, addObserver, activateObserver, removeObserver, flushAsyncObservers, Mixin, mixin, observer, applyMixin, inject, DEBUG_INJECTION_FUNCTIONS, tagForProperty, tagForObject, markObjectAsDirty, tracked, TrackedDescriptor, cached, NAMESPACES, NAMESPACES_BY_ID, addNamespace, findNamespace, findNamespaces, processNamespace, processAllNamespaces, removeNamespace, isSearchDisabled as isNamespaceSearchDisabled, setSearchDisabled as setNamespaceSearchDisabled };
@@ -1,4 +1,8 @@
1
1
  export {};
2
+ /**
3
+ @module @ember/routing
4
+ */
5
+
2
6
  /**
3
7
  A `RouteInfoWithAttributes` is an object that contains
4
8
  metadata, including the resolved value from the routes
@@ -1,4 +1,8 @@
1
1
  "use strict";
2
+ /**
3
+ @module @ember/routing
4
+ */
5
+
2
6
  /**
3
7
  A Transition is a thennable (a promise-like object) that represents
4
8
  an attempt to transition to another route. It can be aborted, either