32 Commits

Author SHA1 Message Date
George Kalpakas
327980bf49 fix(elements): correctly handle getting/setting properties before connecting the element (#36114)
`createCustomElements()` creates some getters/setters for properties
corresponding to component inputs that delegate to the
`NgElementStrategy`. However, it is not guaranteed that the element's
`NgElementStrategy` will have been created when these getters/setters
are called, because some polyfills (e.g. `document-register-element`) do
not call the constructor.

Previously, trying to get/set input properties before connecting the
element to the DOM (via `connectedCallback()`) would fail due to
`NgElementStrategy` not being created.

This commit ensures that the `NgElementStrategy` is always created
before used inside the input property getters/setters (similar to how it
is done for other methods of `NgElement`).

Mentioned in https://github.com/angular/angular/pull/31416/files#r300326698.

PR Close #36114
2020-05-20 09:43:35 -07:00
Joey Perrott
698b0288be build: reformat repo to new clang@1.4.0 (#36613)
PR Close #36613
2020-04-14 12:08:36 -07:00
George Kalpakas
9ba46d9f88 fix(elements): correctly handle setting inputs to undefined (#36140)
Previously, when an input property was initially set to `undefined` it
would not be correctly recognized as a change (and trigger
`ngOnChanges()`).

This commit ensures that explicitly setting an input to `undefined` is
correctly handled the same as setting the property to any other value.
This aligns the behavior of Angular custom elements with that of the
corresponding components when used directly (not as custom elements).

PR Close #36140
2020-03-24 10:29:33 -07:00
George Kalpakas
b14ac96750 fix(elements): correctly set SimpleChange#firstChange for pre-existing inputs (#36140)
Previously, when an input property was set on an `NgElement` before
instantiating the underlying component, the `SimpleChange` object passed
to `ngOnChanges()` would have `firstChange` set to false, even if this
was the first change (as far as the component instance was concerned).

This commit fixes this by ensuring `SimpleChange#firstChange` is set to
true on first change, regardless if the property was set before or after
instantiating the component. This alignthe behavior of Angular custom
elements with that of the corresponding components when used directly
(not as custom elements).

Jira issue: [FW-2007](https://angular-team.atlassian.net/browse/FW-2007)

Fixes #36130

PR Close #36140
2020-03-24 10:29:32 -07:00
Alex Rickabaugh
95c729f5d1 build: typescript 3.8 support (#35864)
This commit adds support in the Angular monorepo and in the Angular
compiler(s) for TypeScript 3.8. All packages can now compile with
TS 3.8.

For most of the repo, only a handful few typings adjustments were needed:

* TS 3.8 has a new `CustomElementConstructor` DOM type, which enforces a
  zero-argument constructor. The `NgElementConstructor` type previously
  declared a required `injector` argument despite the fact that its
  implementation allowed `injector` to be optional. The interface type was
  updated to reflect the optionality of the argument.
* Certain error messages were changed, and expectations in tests were
  updated as a result.
* tsserver (part of language server) now returns performance information in
  responses, so test expectations were changed to only assert on the actual
  body content of responses.

For compiler-cli and schematics (which use the TypeScript AST) a major
breaking change was the introduction of the export form:

```typescript
export * as foo from 'bar';
```

This is a `ts.NamespaceExport`, and the `exportClause` of a
`ts.ExportDeclaration` can now take this type as well as `ts.NamedExports`.
This broke a lot of places where `exportClause` was assumed to be
`ts.NamedExports`.

For the most part these breakages were in cases where it is not necessary
to handle the new `ts.NamedExports` anyway. ngtsc's design uses the
`ts.TypeChecker` APIs to understand syntax and so automatically supports the
new form of exports.

The View Engine compiler on the other hand extracts TS structures into
metadata.json files, and that format was not designed for namespaced
exports. As a result it will take a nontrivial amount of work if we want to
support such exports in View Engine. For now, these new exports are not
accounted for in metadata.json, and so using them in "folded" Angular
expressions will result in errors (probably claiming that the referenced
exported namespace doesn't exist).

Care was taken to only use TS APIs which are present in 3.7/3.6, as Angular
needs to remain compatible with these for the time being.

This commit does not update angular.io.

PR Close #35864
2020-03-10 17:51:20 -04:00
Balint Mero
7151eae36d fix(elements): handle falsy initial value (#31604)
Fixes angular/angular#30834

PR Close #31604
2019-07-18 14:26:37 -07:00
Filipe Silva
ac34a1429b refactor: remove toplevel property accesses (#29329)
PR Close #29329
2019-05-16 12:08:49 -07:00
Pete Bacon Darwin
24521f549c docs: convert all @experimental tags to @publicApi tags (#26595)
PR Close #26595
2018-10-19 14:35:52 -07:00
Igor Minar
9993c72335 feat: add support for TypeScript 3.1 (#26151)
PR Close #26151
2018-09-28 09:34:51 -07:00
George Kalpakas
658f49f650 docs(elements): fix typo (tranformation --> transformation) (#25600)
PR Close #25600
2018-08-23 16:54:49 -04:00
Rado Kirov
c95437f15d build(bazel): Turning on strictPropertyInitialization for Angular. (#24572)
All errors for existing fields have been detected and suppressed with a
`!` assertion.

Issue/24571 is tracking proper clean up of those instances.

One-line change required in ivy/compilation.ts, because it appears that
the new syntax causes tsickle emitted node to no longer track their
original sourceFiles.

PR Close #24572
2018-06-25 07:57:13 -07:00
Vikram Subramanian
d4b8b24406 fix(elements): prevent closure renaming of platform properties (#23843)
Closure compiler with type based optimizations has a bug where externs for inherited static fields are not being honored. For Angular Elements this meant that 'observedAttributes' static field which is marked as an extern for the base HTMLElement class was getting renamed.

This commit works around the bug by using quoted access of 'observedAttributes' that explicitly prevents the renaming.

PR Close #23843
2018-05-11 18:11:48 -04:00
Andrew Seguin
b1cda3639f fix(elements): always check to create strategy (#23825)
PR Close #23825
2018-05-10 16:07:11 -07:00
Vikram Subramanian
af46d097ff fix(elements): avoid exception when window is undefined (#23324)
Detect server environment by checking `typeof window` and schedule render immediately instead of waiting for RAF.

This does not make Angular Elements work on platform-server. This is just the first step.

PR Close #23324
2018-04-11 23:17:04 -07:00
Judy Bogart
ff34d5ea7a docs: add custom elements documentation (#22966)
PR Close #22966
2018-04-02 14:13:46 -07:00
Igor Minar
b43f8bc7d3 feat(core): upgrade rxjs to 6.0.0-alpha.4 (#22573)
PR Close #22573
2018-03-19 21:51:51 -07:00
Andrew Seguin
688096b7a3 feat(elements): remove attribute/input from config (#22413)
PR Close #22413
2018-03-16 12:39:07 -07:00
Andrew Seguin
167fdf745c feat(elements): rename API to createCustomElement (#22413)
PR Close #22413
2018-03-16 12:39:07 -07:00
Andrew Seguin
87f60bccfd feat(elements): injector create (#22413)
PR Close #22413
2018-03-16 12:39:07 -07:00
Andrew Seguin
46efd4b938 feat(elements): George's comments (#22413)
PR Close #22413
2018-03-16 12:39:07 -07:00
Andrew Seguin
19368085aa feat(elements): provide type, not factory; remove config need (#22413)
PR Close #22413
2018-03-16 12:39:07 -07:00
Andrew Seguin
d2be675acc feat(elements): add tests for component factory strategy (#22413)
PR Close #22413
2018-03-16 12:39:07 -07:00
Andrew Seguin
22b96b9690 feat(elements): add support for creating custom elements (#22413)
PR Close #22413
2018-03-16 12:39:07 -07:00
Igor Minar
3997d97806 revert: feat(elements): implement @angular/elements #19469 (#20152)
This PR was merged without API docs and general rollout plan.

We can't release this as is in 5.1 without a plan for documentation, cli integration, etc.
2017-11-03 15:54:54 -07:00
George Kalpakas
dcf8840831 feat(elements): implement registerAsCustomElements()
closes #19469
2017-11-02 16:09:30 -07:00
George Kalpakas
60c0b178af feat(elements): implement NgElements 2017-11-02 16:09:09 -07:00
George Kalpakas
0899f4f8fc feat(elements): implement NgElementConstructor 2017-11-02 16:09:09 -07:00
George Kalpakas
aed4a11d01 feat(elements): implement NgElement 2017-11-02 16:09:09 -07:00
George Kalpakas
75cf70ae04 feat(elements): implement NgElementApplicationContext 2017-11-02 16:09:09 -07:00
George Kalpakas
6b30fbf94e feat(elements): implement extractProjectableNodes() 2017-11-02 16:09:09 -07:00
George Kalpakas
24f17f913a feat(elements): implement utils 2017-11-02 16:09:09 -07:00
George Kalpakas
ebfa204af0 feat(elements): set up the elements package 2017-11-02 16:09:09 -07:00