ember-source 4.3.0-alpha.4 → 4.3.0-beta.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +6 -2
  2. package/build-metadata.json +3 -3
  3. package/dist/dependencies/router_js.js +66 -31
  4. package/dist/ember-template-compiler.js +16 -13
  5. package/dist/ember-template-compiler.map +1 -1
  6. package/dist/ember-testing.js +1 -1
  7. package/dist/ember-testing.map +1 -1
  8. package/dist/ember.debug.js +669 -1204
  9. package/dist/ember.debug.map +1 -1
  10. package/dist/header/license.js +1 -1
  11. package/dist/packages/@ember/-internals/container/index.js +14 -10
  12. package/dist/packages/@ember/-internals/glimmer/index.js +60 -45
  13. package/dist/packages/@ember/-internals/meta/lib/meta.js +8 -9
  14. package/dist/packages/@ember/-internals/metal/index.js +44 -45
  15. package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +10 -8
  16. package/dist/packages/@ember/-internals/routing/lib/services/router.js +153 -191
  17. package/dist/packages/@ember/-internals/routing/lib/system/route-info.js +2 -2
  18. package/dist/packages/@ember/-internals/routing/lib/system/route.js +95 -374
  19. package/dist/packages/@ember/-internals/routing/lib/system/router.js +60 -33
  20. package/dist/packages/@ember/-internals/routing/lib/utils.js +31 -20
  21. package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +32 -32
  22. package/dist/packages/@ember/-internals/utils/index.js +2 -0
  23. package/dist/packages/@ember/-internals/views/lib/system/utils.js +1 -0
  24. package/dist/packages/@ember/canary-features/index.js +2 -2
  25. package/dist/packages/@ember/controller/index.js +3 -54
  26. package/dist/packages/@ember/instrumentation/index.js +9 -13
  27. package/dist/packages/@ember/routing/router-service.js +1 -0
  28. package/dist/packages/@ember/service/index.js +6 -73
  29. package/dist/packages/ember/version.js +1 -1
  30. package/docs/data.json +412 -344
  31. package/package.json +4 -4
@@ -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.3.0-alpha.4
8
+ * @version 4.3.0-beta.1
9
9
  */
@@ -124,7 +124,7 @@ class Container {
124
124
 
125
125
  lookup(fullName, options) {
126
126
  if (this.isDestroyed) {
127
- throw new Error(`Can not call \`.lookup\` after the owner has been destroyed`);
127
+ throw new Error(`Cannot call \`.lookup\` after the owner has been destroyed`);
128
128
  }
129
129
 
130
130
  assert('fullName must be a proper full name', this.registry.isValidFullName(fullName));
@@ -195,7 +195,7 @@ class Container {
195
195
 
196
196
  factoryFor(fullName) {
197
197
  if (this.isDestroyed) {
198
- throw new Error(`Can not call \`.factoryFor\` after the owner has been destroyed`);
198
+ throw new Error(`Cannot call \`.factoryFor\` after the owner has been destroyed`);
199
199
  }
200
200
 
201
201
  let normalizedName = this.registry.normalize(fullName);
@@ -352,9 +352,9 @@ function destroyDestroyables(container) {
352
352
  let cache = container.cache;
353
353
  let keys = Object.keys(cache);
354
354
 
355
- for (let i = 0; i < keys.length; i++) {
356
- let key = keys[i];
355
+ for (let key of keys) {
357
356
  let value = cache[key];
357
+ assert('has cached value', value);
358
358
 
359
359
  if (value.destroy) {
360
360
  value.destroy();
@@ -417,7 +417,7 @@ class FactoryManager {
417
417
  } = this;
418
418
 
419
419
  if (container.isDestroyed) {
420
- throw new Error(`Can not create new instances after the owner has been destroyed (you attempted to create ${this.fullName})`);
420
+ throw new Error(`Cannot create new instances after the owner has been destroyed (you attempted to create ${this.fullName})`);
421
421
  }
422
422
 
423
423
  let props = {};
@@ -781,6 +781,8 @@ class Registry {
781
781
  }
782
782
 
783
783
  let type = fullName.split(':')[0];
784
+ assert('has type', type); // split always will have at least one value
785
+
784
786
  options = this._typeOptions[type];
785
787
 
786
788
  if (options && options[optionName] !== undefined) {
@@ -827,8 +829,7 @@ class Registry {
827
829
  let localKnown = dictionary(null);
828
830
  let registeredNames = Object.keys(this.registrations);
829
831
 
830
- for (let index = 0; index < registeredNames.length; index++) {
831
- let fullName = registeredNames[index];
832
+ for (let fullName of registeredNames) {
832
833
  let itemType = fullName.split(':')[0];
833
834
 
834
835
  if (itemType === type) {
@@ -863,9 +864,11 @@ if (DEBUG) {
863
864
 
864
865
  for (let key in hash) {
865
866
  if (Object.prototype.hasOwnProperty.call(hash, key)) {
867
+ let value = hash[key];
868
+ assert('has value', value);
866
869
  let {
867
870
  specifier
868
- } = hash[key];
871
+ } = value;
869
872
  assert(`Expected a proper full name, given '${specifier}'`, this.isValidFullName(specifier));
870
873
  injections.push({
871
874
  property: key,
@@ -882,10 +885,10 @@ if (DEBUG) {
882
885
  return;
883
886
  }
884
887
 
885
- for (let i = 0; i < injections.length; i++) {
888
+ for (let injection of injections) {
886
889
  let {
887
890
  specifier
888
- } = injections[i];
891
+ } = injection;
889
892
  assert(`Attempting to inject an unknown injection: '${specifier}'`, this.has(specifier));
890
893
  }
891
894
  };
@@ -929,6 +932,7 @@ function has(registry, fullName) {
929
932
  const privateNames = dictionary(null);
930
933
  const privateSuffix = `${Math.random()}${Date.now()}`.replace('.', '');
931
934
  function privatize([fullName]) {
935
+ assert('has a single string argument', arguments.length === 1 && fullName);
932
936
  let name = privateNames[fullName];
933
937
 
934
938
  if (name) {
@@ -1505,7 +1505,11 @@ function installAttributeBinding(component, rootRef, parsed, operations) {
1505
1505
  operations.setAttribute(attribute, reference, false, null);
1506
1506
  }
1507
1507
  function createClassNameBindingRef(rootRef, microsyntax, operations) {
1508
- let [prop, truthy, falsy] = microsyntax.split(':');
1508
+ let parts = microsyntax.split(':');
1509
+ let [prop, truthy, falsy] = parts; // NOTE: This could be an empty string
1510
+
1511
+ assert('has prop', prop !== undefined); // Will always have at least one part
1512
+
1509
1513
  let isStatic = prop === '';
1510
1514
 
1511
1515
  if (isStatic) {
@@ -1889,9 +1893,10 @@ var action$1 = internalHelper(args => {
1889
1893
  // Anything else is an action argument.
1890
1894
 
1891
1895
  let [context, action$$1, ...restArgs] = positional;
1896
+ assert('hash position arguments', context && action$$1);
1892
1897
  let debugKey = action$$1.debugLabel;
1893
- let target = 'target' in named ? named.target : context;
1894
- let processArgs = makeArgsProcessor('value' in named && named.value, restArgs);
1898
+ let target = 'target' in named && named.target ? named.target : context;
1899
+ let processArgs = makeArgsProcessor('value' in named && named.value || false, restArgs);
1895
1900
  let fn$$1;
1896
1901
 
1897
1902
  if (isInvokableRef(action$$1)) {
@@ -2001,6 +2006,7 @@ function processComponentArgs(namedArgs) {
2001
2006
 
2002
2007
  for (let name in namedArgs) {
2003
2008
  let ref = namedArgs[name];
2009
+ assert('expected ref', ref);
2004
2010
  let value = valueForRef(ref);
2005
2011
  let isAction = typeof value === 'function' && ACTIONS.has(value);
2006
2012
 
@@ -2064,6 +2070,7 @@ function applyAttributeBindings(attributeBindings, component, rootRef, operation
2064
2070
 
2065
2071
  while (i !== -1) {
2066
2072
  let binding = attributeBindings[i];
2073
+ assert('has binding', binding);
2067
2074
  let parsed = parseAttributeBinding(binding);
2068
2075
  let attribute = parsed[1];
2069
2076
 
@@ -2143,8 +2150,9 @@ class CurlyComponentManager {
2143
2150
  {
2144
2151
  __ARGS__
2145
2152
  } = _b,
2146
- rest = __rest(_b, ["__ARGS__"]); // does this need to be untracked?
2153
+ rest = __rest(_b, ["__ARGS__"]);
2147
2154
 
2155
+ assert('[BUG] unexpectedly missing __ARGS__ after check', __ARGS__); // does this need to be untracked?
2148
2156
 
2149
2157
  let __args__ = valueForRef(__ARGS__);
2150
2158
 
@@ -2178,14 +2186,8 @@ class CurlyComponentManager {
2178
2186
  Object.assign(named, args.named.capture());
2179
2187
 
2180
2188
  for (let i = 0; i < count; i++) {
2181
- // As of TS 3.7, tsc is giving us the following error on this line without the type annotation
2182
- //
2183
- // TS7022: 'name' implicitly has type 'any' because it does not have a type annotation and is
2184
- // referenced directly or indirectly in its own initializer.
2185
- //
2186
- // This is almost certainly a TypeScript bug, feel free to try and remove the annotation after
2187
- // upgrading if it is not needed anymore.
2188
- const name = positionalParams[i];
2189
+ let name = positionalParams[i];
2190
+ assert('Expected at least one positional param', name);
2189
2191
  assert(`You cannot specify both a positional param (at position ${i}) and the hash argument \`${name}\`.`, !args.named.has(name));
2190
2192
  named[name] = args.positional.at(i);
2191
2193
  }
@@ -2445,9 +2447,7 @@ function processComponentInitializationAssertions(component, props) {
2445
2447
  classNameBindings
2446
2448
  } = component;
2447
2449
 
2448
- for (let i = 0; i < classNameBindings.length; i++) {
2449
- let binding = classNameBindings[i];
2450
-
2450
+ for (let binding of classNameBindings) {
2451
2451
  if (binding.split(' ').length > 1) {
2452
2452
  return false;
2453
2453
  }
@@ -4148,7 +4148,8 @@ class EachInWrapper {
4148
4148
  var eachIn = internalHelper(({
4149
4149
  positional
4150
4150
  }) => {
4151
- let inner = positional[0];
4151
+ const inner = positional[0];
4152
+ assert('expected at least one positional arg', inner);
4152
4153
  return createComputeRef(() => {
4153
4154
  let iterable = valueForRef(inner);
4154
4155
  consumeTag(tagForObject(iterable));
@@ -4287,18 +4288,14 @@ class ObjectIterator extends BoundedIterator {
4287
4288
 
4288
4289
  static fromIndexable(obj) {
4289
4290
  let keys = Object.keys(obj);
4290
- let {
4291
- length
4292
- } = keys;
4293
4291
 
4294
- if (length === 0) {
4292
+ if (keys.length === 0) {
4295
4293
  return null;
4296
4294
  } else {
4297
4295
  let values = [];
4298
4296
 
4299
- for (let i = 0; i < length; i++) {
4297
+ for (let key of keys) {
4300
4298
  let value;
4301
- let key = keys[i];
4302
4299
  value = obj[key]; // Add the tag of the returned value if it is an array, since arrays
4303
4300
  // should always cause updates if they are consumed and then changed
4304
4301
 
@@ -4558,14 +4555,14 @@ var disallowDynamicResolution = internalHelper(({
4558
4555
  positional,
4559
4556
  named
4560
4557
  }) => {
4561
- assert(`[BUG] wrong number of positional arguments, expecting 1, got ${positional.length}`, positional.length === 1);
4562
- let nameOrValueRef = positional[0];
4563
- assert(`[BUG] expecting \`type\` named argument`, 'type' in named);
4564
- assert(`[BUG] expecting \`loc\` named argument`, 'loc' in named);
4565
- assert(`[BUG] expecting \`original\` named argument`, 'original' in named);
4558
+ const nameOrValueRef = positional[0];
4559
+ assert(`[BUG] wrong number of positional arguments, expecting 1, got ${positional.length}`, positional.length === 1 && nameOrValueRef);
4566
4560
  let typeRef = named.type;
4567
4561
  let locRef = named.loc;
4568
- let originalRef = named.original; // Bug: why do these fail?
4562
+ let originalRef = named.original;
4563
+ assert(`[BUG] expecting \`type\` named argument`, typeRef);
4564
+ assert(`[BUG] expecting \`loc\` named argument`, locRef);
4565
+ assert(`[BUG] expecting \`original\` named argument`, originalRef); // Bug: why do these fail?
4569
4566
  // assert('[BUG] expecting a string literal for the `type` argument', isConstRef(typeRef));
4570
4567
  // assert('[BUG] expecting a string literal for the `loc` argument', isConstRef(locRef));
4571
4568
  // assert('[BUG] expecting a string literal for the `original` argument', isConstRef(originalRef));
@@ -4587,7 +4584,8 @@ let helper$1;
4587
4584
 
4588
4585
  if (DEBUG) {
4589
4586
  helper$1 = args => {
4590
- let inner = args.positional[0];
4587
+ const inner = args.positional[0];
4588
+ assert('expected at least one positional arg', inner);
4591
4589
  return createComputeRef(() => {
4592
4590
  let value = valueForRef(inner);
4593
4591
  assert('You cannot pass a null or undefined destination element to in-element', value !== null && value !== undefined);
@@ -4595,7 +4593,11 @@ if (DEBUG) {
4595
4593
  });
4596
4594
  };
4597
4595
  } else {
4598
- helper$1 = args => args.positional[0];
4596
+ helper$1 = args => {
4597
+ let arg = args.positional[0];
4598
+ assert('expected at least one positional arg', arg);
4599
+ return arg;
4600
+ };
4599
4601
  }
4600
4602
 
4601
4603
  var inElementNullCheckHelper = internalHelper(helper$1);
@@ -4604,9 +4606,14 @@ var normalizeClassHelper = internalHelper(({
4604
4606
  positional
4605
4607
  }) => {
4606
4608
  return createComputeRef(() => {
4607
- let classNameParts = valueForRef(positional[0]).split('.');
4609
+ let classNameArg = positional[0];
4610
+ let valueArg = positional[1];
4611
+ assert('expected at least two positional args', classNameArg && valueArg);
4612
+ let classNameParts = valueForRef(classNameArg).split('.');
4608
4613
  let className = classNameParts[classNameParts.length - 1];
4609
- let value = valueForRef(positional[1]);
4614
+ assert('has className', className); // Always at least one split result
4615
+
4616
+ let value = valueForRef(valueArg);
4610
4617
 
4611
4618
  if (value === true) {
4612
4619
  return dasherize(className);
@@ -4627,7 +4634,7 @@ var resolve = internalHelper(({
4627
4634
  assert('[BUG] missing owner', owner);
4628
4635
  assert(`[BUG] wrong number of positional arguments, expecting 1, got ${positional.length}`, positional.length === 1);
4629
4636
  let fullNameRef = positional[0];
4630
- assert('[BUG] expecting a string literal as argument', isConstRef(fullNameRef));
4637
+ assert('[BUG] expecting a string literal as argument', fullNameRef && isConstRef(fullNameRef));
4631
4638
  let fullName = valueForRef(fullNameRef);
4632
4639
  assert('[BUG] expecting a string literal as argument', typeof fullName === 'string');
4633
4640
  assert('[BUG] expecting a valid full name', fullName.split(':').length === 2);
@@ -4652,7 +4659,8 @@ var resolve = internalHelper(({
4652
4659
  var trackArray = internalHelper(({
4653
4660
  positional
4654
4661
  }) => {
4655
- let inner = positional[0];
4662
+ const inner = positional[0];
4663
+ assert('expected at least one positional arg', inner);
4656
4664
  return createComputeRef(() => {
4657
4665
  let iterable = valueForRef(inner);
4658
4666
 
@@ -4744,7 +4752,8 @@ var trackArray = internalHelper(({
4744
4752
  var mut = internalHelper(({
4745
4753
  positional
4746
4754
  }) => {
4747
- let ref = positional[0]; // TODO: Improve this error message. This covers at least two distinct
4755
+ let ref = positional[0];
4756
+ assert('expected at least one positional arg', ref); // TODO: Improve this error message. This covers at least two distinct
4748
4757
  // cases:
4749
4758
  //
4750
4759
  // 1. (mut "not a path") – passing a literal, result from a helper
@@ -4880,7 +4889,9 @@ var mut = internalHelper(({
4880
4889
  var readonly = internalHelper(({
4881
4890
  positional
4882
4891
  }) => {
4883
- return createReadOnlyRef(positional[0]);
4892
+ let firstArg = positional[0];
4893
+ assert('has first arg', firstArg);
4894
+ return createReadOnlyRef(firstArg);
4884
4895
  });
4885
4896
 
4886
4897
  /**
@@ -4919,7 +4930,7 @@ var unbound = internalHelper(({
4919
4930
  named
4920
4931
  }) => {
4921
4932
  assert('unbound helper cannot be called with multiple params or hash params', positional.length === 1 && Object.keys(named).length === 0);
4922
- return createUnboundRef(valueForRef(positional[0]), '(resurt of an `unbound` helper)');
4933
+ return createUnboundRef(valueForRef(positional[0]), '(result of an `unbound` helper)');
4923
4934
  });
4924
4935
 
4925
4936
  const MODIFIERS = ['alt', 'shift', 'meta', 'ctrl'];
@@ -5138,6 +5149,7 @@ class ActionModifierManager {
5138
5149
  positional
5139
5150
  } = actionState;
5140
5151
  let actionNameRef = positional[1];
5152
+ assert('Expected at least one positional arg', actionNameRef);
5141
5153
 
5142
5154
  if (!isInvokableRef(actionNameRef)) {
5143
5155
  actionState.actionName = valueForRef(actionNameRef);
@@ -5431,7 +5443,9 @@ const outletHelper = internalHelper((args, owner, scope) => {
5431
5443
  if (args.positional.length === 0) {
5432
5444
  nameRef = createPrimitiveRef('main');
5433
5445
  } else {
5434
- nameRef = args.positional[0];
5446
+ let maybeNameRef = args.positional[0];
5447
+ assert('Expected at least one positional arg', maybeNameRef);
5448
+ nameRef = maybeNameRef;
5435
5449
  }
5436
5450
 
5437
5451
  let outletRef = createComputeRef(() => {
@@ -5871,8 +5885,8 @@ function deregister(renderer) {
5871
5885
  }
5872
5886
 
5873
5887
  function loopBegin() {
5874
- for (let i = 0; i < renderers.length; i++) {
5875
- renderers[i]._scheduleRevalidate();
5888
+ for (let renderer of renderers) {
5889
+ renderer._scheduleRevalidate();
5876
5890
  }
5877
5891
  }
5878
5892
 
@@ -5917,12 +5931,12 @@ function resolveRenderPromise() {
5917
5931
  let loops = 0;
5918
5932
 
5919
5933
  function loopEnd() {
5920
- for (let i = 0; i < renderers.length; i++) {
5921
- if (!renderers[i]._isValid()) {
5934
+ for (let renderer of renderers) {
5935
+ if (!renderer._isValid()) {
5922
5936
  if (loops > ENV._RERENDER_LOOP_LIMIT) {
5923
5937
  loops = 0; // TODO: do something better
5924
5938
 
5925
- renderers[i].destroy();
5939
+ renderer.destroy();
5926
5940
  throw new Error('infinite rendering invalidation detected');
5927
5941
  }
5928
5942
 
@@ -6045,6 +6059,7 @@ class Renderer {
6045
6059
 
6046
6060
  while (i--) {
6047
6061
  let root = roots[i];
6062
+ assert('has root', root);
6048
6063
 
6049
6064
  if (root.isFor(view)) {
6050
6065
  root.destroy();
@@ -6116,6 +6131,7 @@ class Renderer {
6116
6131
  // each root is processed
6117
6132
  for (let i = 0; i < roots.length; i++) {
6118
6133
  let root = roots[i];
6134
+ assert('has root', root);
6119
6135
 
6120
6136
  if (root.destroyed) {
6121
6137
  // add to the list of roots to be removed
@@ -6178,8 +6194,7 @@ class Renderer {
6178
6194
  _clearAllRoots() {
6179
6195
  let roots = this._roots;
6180
6196
 
6181
- for (let i = 0; i < roots.length; i++) {
6182
- let root = roots[i];
6197
+ for (let root of roots) {
6183
6198
  root.destroy();
6184
6199
  }
6185
6200
 
@@ -356,7 +356,8 @@ export class Meta {
356
356
  sync
357
357
  });
358
358
  } else {
359
- let listener = listeners[i]; // If the listener is our own listener and we are trying to remove it, we
359
+ let listener = listeners[i];
360
+ assert('has listener', listener); // If the listener is our own listener and we are trying to remove it, we
360
361
  // want to splice it out entirely so we don't hold onto a reference.
361
362
 
362
363
  if (kind === 2
@@ -447,8 +448,7 @@ export class Meta {
447
448
  this._inheritedEnd = 0;
448
449
  }
449
450
 
450
- for (let i = 0; i < parentListeners.length; i++) {
451
- let listener = parentListeners[i];
451
+ for (let listener of parentListeners) {
452
452
  let index = indexOfListener(listeners, listener.event, listener.target, listener.method);
453
453
 
454
454
  if (index === -1) {
@@ -481,10 +481,9 @@ export class Meta {
481
481
  }
482
482
 
483
483
  if (listeners !== undefined) {
484
- for (let index = 0; index < listeners.length; index++) {
485
- let listener = listeners[index]; // REMOVE listeners are placeholders that tell us not to
484
+ for (let listener of listeners) {
485
+ // REMOVE listeners are placeholders that tell us not to
486
486
  // inherit, so they never match. Only ADD and ONCE can match.
487
-
488
487
  if (listener.event === eventName && (listener.kind === 0
489
488
  /* ADD */
490
489
  || listener.kind === 1
@@ -517,10 +516,9 @@ export class Meta {
517
516
  }
518
517
 
519
518
  if (listeners !== undefined) {
520
- for (let index = 0; index < listeners.length; index++) {
521
- let listener = listeners[index]; // REMOVE listeners are placeholders that tell us not to
519
+ for (let listener of listeners) {
520
+ // REMOVE listeners are placeholders that tell us not to
522
521
  // inherit, so they never match. Only ADD and ONCE can match.
523
-
524
522
  if ((listener.kind === 0
525
523
  /* ADD */
526
524
  || listener.kind === 1
@@ -642,6 +640,7 @@ export { counters };
642
640
  function indexOfListener(listeners, event, target, method) {
643
641
  for (let i = listeners.length - 1; i >= 0; i--) {
644
642
  let listener = listeners[i];
643
+ assert('has listener', listener);
645
644
 
646
645
  if (listener.event === event && listener.target === target && listener.method === method) {
647
646
  return i;
@@ -685,8 +685,7 @@ function finishLazyChains(meta$$1, key, value) {
685
685
  }
686
686
 
687
687
  if (isObject(value)) {
688
- for (let i = 0; i < lazyTags.length; i++) {
689
- let [tag, deps] = lazyTags[i];
688
+ for (let [tag, deps] of lazyTags) {
690
689
  updateTag(tag, getChainTagsForKey(value, deps, tagMetaFor(value), peekMeta(value)));
691
690
  }
692
691
  }
@@ -696,8 +695,8 @@ function finishLazyChains(meta$$1, key, value) {
696
695
  function getChainTagsForKeys(obj, keys, tagMeta, meta$$1) {
697
696
  let tags = [];
698
697
 
699
- for (let i = 0; i < keys.length; i++) {
700
- getChainTags(tags, obj, keys[i], tagMeta, meta$$1);
698
+ for (let key of keys) {
699
+ getChainTags(tags, obj, key, tagMeta, meta$$1);
701
700
  }
702
701
 
703
702
  return combine(tags);
@@ -1313,8 +1312,8 @@ class ComputedProperty extends ComputedDescriptor {
1313
1312
  args.push(property);
1314
1313
  }
1315
1314
 
1316
- for (let i = 0; i < passedArgs.length; i++) {
1317
- expandProperties(passedArgs[i], addArg);
1315
+ for (let arg of passedArgs) {
1316
+ expandProperties(arg, addArg);
1318
1317
  }
1319
1318
 
1320
1319
  this._dependentKeys = args;
@@ -1603,13 +1602,16 @@ function computed(...args) {
1603
1602
  assert(`@computed can only be used directly as a native decorator. If you're using tracked in classic classes, add parenthesis to call it like a function: computed()`, !(isElementDescriptor(args.slice(0, 3)) && args.length === 5 && args[4] === true));
1604
1603
 
1605
1604
  if (isElementDescriptor(args)) {
1605
+ // SAFETY: We passed in the impl for this class
1606
1606
  let decorator = makeComputedDecorator(new ComputedProperty([]), ComputedDecoratorImpl);
1607
1607
  return decorator(args[0], args[1], args[2]);
1608
- }
1608
+ } // SAFETY: We passed in the impl for this class
1609
+
1609
1610
 
1610
1611
  return makeComputedDecorator(new ComputedProperty(args), ComputedDecoratorImpl);
1611
1612
  }
1612
1613
  function autoComputed(...config) {
1614
+ // SAFETY: We passed in the impl for this class
1613
1615
  return makeComputedDecorator(new AutoComputedProperty(config), ComputedDecoratorImpl);
1614
1616
  }
1615
1617
  /**
@@ -1816,12 +1818,12 @@ function _getPath(root, path) {
1816
1818
  let obj = root;
1817
1819
  let parts = typeof path === 'string' ? path.split('.') : path;
1818
1820
 
1819
- for (let i = 0; i < parts.length; i++) {
1821
+ for (let part of parts) {
1820
1822
  if (obj === undefined || obj === null || obj.isDestroyed) {
1821
1823
  return undefined;
1822
1824
  }
1823
1825
 
1824
- obj = _getProp(obj, parts[i]);
1826
+ obj = _getProp(obj, part);
1825
1827
  }
1826
1828
 
1827
1829
  return obj;
@@ -1973,7 +1975,8 @@ function trySet(root, path, value) {
1973
1975
  }
1974
1976
 
1975
1977
  function alias(altKey) {
1976
- assert('You attempted to use @alias as a decorator directly, but it requires a `altKey` parameter', !isElementDescriptor(Array.prototype.slice.call(arguments)));
1978
+ assert('You attempted to use @alias as a decorator directly, but it requires a `altKey` parameter', !isElementDescriptor(Array.prototype.slice.call(arguments))); // SAFETY: We passed in the impl for this class
1979
+
1977
1980
  return makeComputedDecorator(new AliasedProperty(altKey), AliasDecoratorImpl);
1978
1981
  } // TODO: This class can be svelted once `meta` has been deprecated
1979
1982
 
@@ -2312,11 +2315,10 @@ class Libraries {
2312
2315
 
2313
2316
  _getLibraryByName(name) {
2314
2317
  let libs = this._registry;
2315
- let count = libs.length;
2316
2318
 
2317
- for (let i = 0; i < count; i++) {
2318
- if (libs[i].name === name) {
2319
- return libs[i];
2319
+ for (let lib of libs) {
2320
+ if (lib.name === name) {
2321
+ return lib;
2320
2322
  }
2321
2323
  }
2322
2324
 
@@ -2368,8 +2370,7 @@ if (DEBUG) {
2368
2370
  let maxNameLength = Math.max.apply(null, nameLengths);
2369
2371
  debug('-------------------------------');
2370
2372
 
2371
- for (let i = 0; i < libs.length; i++) {
2372
- let lib = libs[i];
2373
+ for (let lib of libs) {
2373
2374
  let spaces = new Array(maxNameLength - lib.name.length + 1).join(' ');
2374
2375
  debug([lib.name, spaces, ' : ', lib.version].join(''));
2375
2376
  }
@@ -2434,10 +2435,8 @@ function setProperties(obj, properties) {
2434
2435
 
2435
2436
  changeProperties(() => {
2436
2437
  let props = Object.keys(properties);
2437
- let propertyName;
2438
2438
 
2439
- for (let i = 0; i < props.length; i++) {
2440
- propertyName = props[i];
2439
+ for (let propertyName of props) {
2441
2440
  set(obj, propertyName, properties[propertyName]);
2442
2441
  }
2443
2442
  });
@@ -2484,9 +2483,8 @@ function findNamespaces() {
2484
2483
  let lookup = context.lookup;
2485
2484
  let keys = Object.keys(lookup);
2486
2485
 
2487
- for (let i = 0; i < keys.length; i++) {
2488
- let key = keys[i]; // Only process entities that start with uppercase A-Z
2489
-
2486
+ for (let key of keys) {
2487
+ // Only process entities that start with uppercase A-Z
2490
2488
  if (!isUppercase(key.charCodeAt(0))) {
2491
2489
  continue;
2492
2490
  }
@@ -2519,8 +2517,8 @@ function processAllNamespaces() {
2519
2517
  if (unprocessedNamespaces || unprocessedMixins) {
2520
2518
  let namespaces = NAMESPACES;
2521
2519
 
2522
- for (let i = 0; i < namespaces.length; i++) {
2523
- processNamespace(namespaces[i]);
2520
+ for (let namespace of namespaces) {
2521
+ processNamespace(namespace);
2524
2522
  }
2525
2523
 
2526
2524
  unprocessedMixins = false;
@@ -2596,10 +2594,7 @@ const {
2596
2594
 
2597
2595
  function extractAccessors(properties) {
2598
2596
  if (properties !== undefined) {
2599
- let keys = Object.keys(properties);
2600
-
2601
- for (let i = 0; i < keys.length; i++) {
2602
- let key = keys[i];
2597
+ for (let key of Object.keys(properties)) {
2603
2598
  let desc = Object.getOwnPropertyDescriptor(properties, key);
2604
2599
 
2605
2600
  if (desc.get !== undefined || desc.set !== undefined) {
@@ -2681,7 +2676,8 @@ function giveDecoratorSuper(key, decorator, property, descs) {
2681
2676
  }]);
2682
2677
  newProperty._readOnly = property._readOnly;
2683
2678
  newProperty._meta = property._meta;
2684
- newProperty.enumerable = property.enumerable;
2679
+ newProperty.enumerable = property.enumerable; // SAFETY: We passed in the impl for this class
2680
+
2685
2681
  return makeComputedDecorator(newProperty, ComputedProperty);
2686
2682
  }
2687
2683
 
@@ -2732,8 +2728,7 @@ function applyMergedProperties(key, value, values) {
2732
2728
  let hasFunction = false;
2733
2729
  let props = Object.keys(value);
2734
2730
 
2735
- for (let i = 0; i < props.length; i++) {
2736
- let prop = props[i];
2731
+ for (let prop of props) {
2737
2732
  let propValue = value[prop];
2738
2733
 
2739
2734
  if (typeof propValue === 'function') {
@@ -2796,8 +2791,7 @@ function mergeProps(meta$$1, props, descs, values, base, keys, keysWithSuper) {
2796
2791
  let mergings = concatenatedMixinProperties('mergedProperties', props, values, base);
2797
2792
  let propKeys = Object.keys(props);
2798
2793
 
2799
- for (let i = 0; i < propKeys.length; i++) {
2800
- let key = propKeys[i];
2794
+ for (let key of propKeys) {
2801
2795
  let value = props[key];
2802
2796
  if (value === undefined) continue;
2803
2797
 
@@ -2860,16 +2854,16 @@ function updateObserversAndListeners(obj, key, fn, add) {
2860
2854
  if (observers !== undefined) {
2861
2855
  let updateObserver = add ? addObserver : removeObserver;
2862
2856
 
2863
- for (let i = 0; i < observers.paths.length; i++) {
2864
- updateObserver(obj, observers.paths[i], null, key, observers.sync);
2857
+ for (let path of observers.paths) {
2858
+ updateObserver(obj, path, null, key, observers.sync);
2865
2859
  }
2866
2860
  }
2867
2861
 
2868
2862
  if (listeners !== undefined) {
2869
2863
  let updateListener = add ? addListener : removeListener;
2870
2864
 
2871
- for (let i = 0; i < listeners.length; i++) {
2872
- updateListener(obj, listeners[i], null, key);
2865
+ for (let listener of listeners) {
2866
+ updateListener(obj, listener, null, key);
2873
2867
  }
2874
2868
  }
2875
2869
  }
@@ -2890,8 +2884,7 @@ function applyMixin(obj, mixins, _hideKeys = false) {
2890
2884
 
2891
2885
  mergeMixins(mixins, meta$$1, descs, values, obj, keys, keysWithSuper);
2892
2886
 
2893
- for (let i = 0; i < keys.length; i++) {
2894
- let key = keys[i];
2887
+ for (let key of keys) {
2895
2888
  let value = values[key];
2896
2889
  let desc = descs[key];
2897
2890
 
@@ -3288,8 +3281,8 @@ function observer(...args) {
3288
3281
  assert('observer called without sync', typeof sync === 'boolean');
3289
3282
  let paths = [];
3290
3283
 
3291
- for (let i = 0; i < dependentKeys.length; ++i) {
3292
- expandProperties(dependentKeys[i], path => paths.push(path));
3284
+ for (let dependentKey of dependentKeys) {
3285
+ expandProperties(dependentKey, path => paths.push(path));
3293
3286
  }
3294
3287
 
3295
3288
  setObservers(func, {
@@ -3307,8 +3300,14 @@ if (DEBUG) {
3307
3300
 
3308
3301
  function inject(type, ...args) {
3309
3302
  assert('a string type must be provided to inject', typeof type === 'string');
3310
- let calledAsDecorator = isElementDescriptor(args);
3311
- let name = calledAsDecorator ? undefined : args[0];
3303
+ let elementDescriptor;
3304
+ let name;
3305
+
3306
+ if (isElementDescriptor(args)) {
3307
+ elementDescriptor = args;
3308
+ } else if (typeof args[0] === 'string') {
3309
+ name = args[0];
3310
+ }
3312
3311
 
3313
3312
  let getInjection = function (propertyName) {
3314
3313
  let owner = getOwner(this) || this.container; // fallback to `container` for backwards compat
@@ -3333,8 +3332,8 @@ function inject(type, ...args) {
3333
3332
 
3334
3333
  });
3335
3334
 
3336
- if (calledAsDecorator) {
3337
- return decorator(args[0], args[1], args[2]);
3335
+ if (elementDescriptor) {
3336
+ return decorator(elementDescriptor[0], elementDescriptor[1], elementDescriptor[2]);
3338
3337
  } else {
3339
3338
  return decorator;
3340
3339
  }