Commit Graph

539 Commits

Author SHA1 Message Date
Victor Berchet f7fba74c58 feat(compiler): do not parse xtb messages not needed by angular (#14111)
fixes #14046

PR Close #14111
2017-01-27 11:52:57 -06:00
Bowen Ni 665dde2e5c refactor(compiler): improve error messages in aot compiler (#14017)
Previously aot compiler prints stack traces when it fails to resolve.
New behavior: aot compiler outputs the error message.
Example: https://gist.github.com/bowenni/a7fe81d916e8cd4a06b0e133436f40fb

PR Close #14017
2017-01-27 11:49:38 -06:00
Victor Berchet 05b2b49711 fix(compiler): allow empty translations for attributes (#14085)
fixes #13897
2017-01-25 17:43:19 -08:00
Alex Rickabaugh d2859cdd71 style(compiler): run format 2017-01-25 13:17:18 -08:00
Victor Berchet a733444d0e docs(compiler): add comment to warn about regexp changes (#14106)
ref #14082
2017-01-25 10:27:18 -08:00
Victor Berchet b2f9d56577 fix(compiler): fix regexp to support firefox 31 (#14082)
fixes #14029
closes #13900
2017-01-24 14:47:51 -08:00
Victor Berchet 1c24271daf refactor(compiler): [i18n] integrate review feedback 2017-01-24 14:47:04 -08:00
Victor Berchet c3e5ddbe20 refactor(compiler): [i18n] move dedup and placeholder mapping to the `MessageBundle`
It makes implementing a `Serializer` simpler as implementations do not have to
care any more about message dedup and placeholder mapping.
2017-01-24 14:47:04 -08:00
Victor Berchet d02eab498f fix(compiler): [i18n] XMB/XTB placeholder names can contain only A-Z, 0-9, _n
There are restrictions on the character set that can be used for xmb and xtb
placeholder names.

However because changing the placeholder names would change the message IDs it
is not possible to add those restrictions to the names used internally. Then we
have to map internal name to public names when generating an xmb file and back
when translating using an xtb file.

Note for implementors of `Serializer`:
- When writing a file, the implementor should take care of converting the
internal names to public names while visiting the message nodes - this is
required because the original nodes are needed to compute the message ID.
- When reading a file, the implementor does not need to take care of the mapping
back to internal names as this is handled in the `I18nToHtmlVisitor` used by the
`TranslationBundle`.

fixes b/34339636
2017-01-24 14:47:04 -08:00
Miško Hevery d169c2434e feat(core): Add type information to injector.get() (#13785)
- Introduce `InjectionToken<T>` which is a parameterized and type-safe
  version of `OpaqueToken`.

DEPRECATION:
- `OpaqueToken` is now deprecated, use `InjectionToken<T>` instead.
- `Injector.get(token: any, notFoundValue?: any): any` is now deprecated
  use the same method which is now overloaded as
  `Injector.get<T>(token: Type<T>|InjectionToken<T>, notFoundValue?: T): T;`.

Migration
- Replace `OpaqueToken` with `InjectionToken<?>` and parameterize it.
- Migrate your code to only use `Type<?>` or `InjectionToken<?>` as
  injection tokens. Using other tokens will not be supported in the
  future.

BREAKING CHANGE:
- Because `injector.get()` is now parameterize it is possible that code
  which used to work no longer type checks. Example would be if one
  injects `Foo` but configures it as `{provide: Foo, useClass: MockFoo}`.
  The injection instance will be that of `MockFoo` but the type will be
  `Foo` instead of `any` as in the past. This means that it was possible
  to call a method on `MockFoo` in the past which now will fail type
  check. See this example:

```
class Foo {}
class MockFoo extends Foo {
  setupMock();
}

var PROVIDERS = [
  {provide: Foo, useClass: MockFoo}
];

...

function myTest(injector: Injector) {
  var foo = injector.get(Foo);
  // This line used to work since `foo` used to be `any` before this
  // change, it will now be `Foo`, and `Foo` does not have `setUpMock()`.
  // The fix is to downcast: `injector.get(Foo) as MockFoo`.
  foo.setUpMock();
}
```

PR Close #13785
2017-01-17 15:34:54 -06:00
Matias Niemelä c2aa981dd6 fix(animations): fix internal jscompiler issue and AOT quoting (#13798)
CL #143630929
PR Close #13798
2017-01-13 13:52:00 -06:00
Victor Berchet 424e6c4cb9 fix(i18n): translate attributes inside elements marked for translation
fixes #13796
fixes #13814
2017-01-09 19:33:03 -05:00
Victor Berchet 78f42c7aa1 refactor(Compiler): misc cleanup 2017-01-09 19:32:01 -05:00
Chuck Jazdzewski d061adc02d fix(compiler): avoid evaluating arguments to unknown decorators
Fixes #13605
2017-01-09 16:30:31 -05:00
Ryan Cavanaugh 99aa49ab6c feat(language-service): support TS2.2 plugin model 2017-01-09 15:00:40 -05:00
Victor Berchet e5c6bb4286 fix(Compiler): fix template binding parsing (`*directive="-..."`)
fixes #13800
2017-01-09 15:00:40 -05:00
Matias Niemelä 9211a22039 feat(animations): support function types in transitions
Closes #13538
Closes #13537
2017-01-06 19:29:46 -05:00
Matias Niemelä 3f67ab074a feat(animations): expose the `triggerName` within the transition event
Closes #13600
2017-01-06 19:29:45 -05:00
Matias Niemelä 4bae4b3bb5 feat(animations): expose the `element` value within transition events 2017-01-06 19:29:45 -05:00
Victor Berchet 1bd04e95de refactor: remove unused imports 2017-01-05 11:18:34 -08:00
Tobias Bosch db49d422f2 refactor(compiler): generate less code for bindings to DOM elements
Detailed changes:
- remove `UNINITIALIZED`, initialize change detection fields with `undefined`.
  * we use `view.numberOfChecks === 0` now everywhere
    as indicator whether we are in the first change detection cycle
    (previously we used this only in a couple of places).
  * we keep the initialization itself as change detection get slower without it.
- remove passing around `throwOnChange` in various generated calls,
  and store it on the view as property instead.
- change generated code for bindings to DOM elements as follows:
  Before:
  ```
  var currVal_10 = self.context.bgColor;
  if (jit_checkBinding15(self.throwOnChange,self._expr_10,currVal_10)) {
    self.renderer.setElementStyle(self._el_0,'backgroundColor',((self.viewUtils.sanitizer.sanitize(jit_21,currVal_10) == null)? null: self.viewUtils.sanitizer.sanitize(jit_21,currVal_10).toString()));
    self._expr_10 = currVal_10;
  }
  var currVal_11 = jit_inlineInterpolate16(1,' ',self.context.data.value,' ');
  if (jit_checkBinding15(self.throwOnChange,self._expr_11,currVal_11)) {
    self.renderer.setText(self._text_1,currVal_11);
    self._expr_11 = currVal_11;
  }
  ```,
  After:
  ```
  var currVal_10 = self.context.bgColor;
  jit_checkRenderStyle14(self,self._el_0,'backgroundColor',null,self._expr_10,self._expr_10=currVal_10,false,jit_21);
  var currVal_11 = jit_inlineInterpolate15(1,' ',self.context.data.value,' ');
  jit_checkRenderText16(self,self._text_1,self._expr_11,self._expr_11=currVal_11,false);
  ```

Performance impact:
- None seen (checked against internal latency lab)

Part of #13651
2017-01-03 13:05:05 -08:00
Dzmitry Shylovich 6b02b80a03 fix(compiler): improve error message for undefined providers (#13546)
Closes #10835
2016-12-27 17:05:14 -08:00
Dzmitry Shylovich 2c0c86e3ce
fix(compiler): improve the error when template is not a string
Closes #8708
Closes #13377
2016-12-27 17:04:16 -08:00
Dzmitry Shylovich 5b4bea24de
refactor(compiler): clean up directive normalizer 2016-12-27 17:03:58 -08:00
Tobias Bosch 7c210645a3 fix(compiler): query `<template>` elements before their children. (#13677)
Fixes #13118
Closes #13167
2016-12-27 16:28:54 -08:00
Victor Berchet 0ac8e102de
test(i18n): add extraction to integration specs
Closes #13648.
2016-12-27 15:32:54 -08:00
Victor Berchet e74d8aaf92
fix(i18n): parse ICU messages while normalizing templates
Fixes:
- Inject the i18n specific HtmlParser into the directive normalizer,
- Parse ICU messages while normalizing templates,
- Normalize (visit) the content of ICU messages.

🎄🎁🎅
2016-12-27 15:32:43 -08:00
Victor Berchet 881eb894bc fix(Compiler): allow "." in attribute selectors (#13653)
fixes #13645
2016-12-27 15:23:49 -08:00
Victor Berchet eed83443b8 chore(tslint): update tslint to 4.x (#13603) 2016-12-27 14:55:58 -08:00
Dzmitry Shylovich 445ed43b9a fix(compiler): throw an error for invalid provider (#13544)
Closes #8870
2016-12-27 14:02:28 -08:00
Tobias Bosch 9c697030e6 feat(compiler): generate proper reexports in `.ngfactory.ts` files to not need transitive deps for compiling `.ngfactory.ts` files. (#13524)
Note: This checks the constructors of `@Injectable` classes more strictly.
E.g this will fail now as the constructor argument has no `@Inject` nor is
the type of the argument a DI token.

```
@Injectable()
class MyService {
  constructor(dep: string) {}
}
```

Last part of #12787
Closes #12787
2016-12-27 09:36:47 -08:00
Matias Niemelä f49ab56160 fix(animations): always quote string map key values in AOT code (#13602) 2016-12-20 18:17:58 -08:00
Dzmitry Shylovich c0f750af4e fix(compiler): ignore @import in comments (#13368)
* refactor(compiler): clean up style url resolver
* fix(compiler): ignore @import in css comments

Closes #12196
2016-12-20 17:51:02 -08:00
Victor Berchet 6b65fc1286 feat(compiler-cli): private i18n API for the CLI (#13536)
Also change the Extractor API to align with the Codegen API (internal APIs)
2016-12-19 11:56:10 -08:00
Victor Berchet e78508507d fix(compiler): do not lex `}}` when interpolation is disabled (#13531)
* doc(compiler): fix the ICU expander API docs

* test(compiler): add lexer and parser specs

* fix(compiler): do not lex `}}` when interpolation is disabled

fix #13525
2016-12-16 15:33:16 -08:00
Marc Laval 55dfa1b69d test(forms): refactor integration tests to improve speed (#13500) 2016-12-15 17:07:26 -08:00
Victor Berchet 0fe3cd9a4c fix(i18n): add a default example to xmb placeholders (#13507)
Otherwise the TC would not be able to load the message
2016-12-15 15:33:42 -08:00
Chuck Jazdzewski 5b6e8ea3ec refactor(compiler): format update (#13506) 2016-12-15 13:54:38 -08:00
Bowen Ni f0e092515c refactor(compiler): don't print stack trace on template parse errors (#13390) 2016-12-15 13:07:12 -08:00
Tobias Bosch 33910ddfc9 refactor(compiler): store metadata of top level symbols also in summaries (#13289)
This allows a build using summaries to not need .metadata.json files at all
any more.

Part of #12787
2016-12-15 09:12:40 -08:00
Chuck Jazdzewski b6078f5887 fix(compiler): update to metadata version 3 (#13464)
This change retracts support for metadata version 2.

The collector used to produce version 2 metadata was incomplete
and can cause the AOT compiler to fail to resolve symbols or
produce other spurious errors.

All libraries compiled and published with 2.3.0 ngc will need
to be recompiled and updated with this change.
2016-12-14 15:28:51 -08:00
Victor Berchet c65b4fa9dc refactor: format & lint 2016-12-14 15:10:43 -08:00
Victor Berchet aa40366a92 fix(compiler): fix simplify a reference without a name
closes #13470
2016-12-14 14:33:10 -08:00
Alex Rickabaugh aa3769ba69 fix(compiler): resolver should merge host bindings and listeners (#13474)
fixes #13327
2016-12-14 14:31:57 -08:00
Victor Berchet d4ddb6004e refactor: format & lint 2016-12-14 13:05:04 -08:00
Eudes Petonnet-Vincent d91a86aac6 fix(upgrade): fix downgrade content projection and injector inheritance
- Full support for content projection in downgraded Angular 2
  components. In particular, this enables multi-slot projection and
  other features on <ng-content>.
- Correctly wire up hierarchical injectors for downgraded Angular 2
  components: downgraded components inherit the injector of the first
  other downgraded Angular 2 component they find up the DOM tree.

Closes #6629, #7727, #8729, #9643, #9649, #12675
2016-12-14 13:02:27 -08:00
Peter Bacon Darwin 3e90605db9 refactor(compiler/template_parser): export `createElementCssSelector`
This is needed in `ngUpgrade`.
2016-12-14 13:02:27 -08:00
Miško Hevery a659259962 fix(core): detectChanges() doesn't work on detached instance
Closes #13426
Closes #13472
2016-12-14 13:01:06 -08:00
Matias Niemelä b56474d067 fix(animations): throw errors and normalize offset beyond the range of [0,1]
Closes #13348
Closes #13440
2016-12-14 12:59:47 -08:00
Matias Niemelä 8395f0e138 perf(animations): always run the animation queue outside of zones
Related #12732
Closes #13440
2016-12-14 12:59:36 -08:00