Commit Graph

663 Commits

Author SHA1 Message Date
Matias Niemelä 724707c6e4 feat(ivy): improve debugging experience for styles/classes (#33179)
This patch introduces the `printTable()` and `printSources()`
methods to `DebugStylingContext` which can be used via the
`window.ng.getDebugNode` helpers when debugging an application.

PR Close #33179
2019-10-17 00:35:17 -04:00
Kara Erickson 86104b82b8 refactor(core): rename ngInjectableDef to ɵprov (#33151)
Injectable defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngInjectableDef to "prov" (for "provider", since injector defs
are known as "inj"). This is because property names cannot
be minified by Uglify without turning on property mangling
(which most apps have turned off) and are thus size-sensitive.

PR Close #33151
2019-10-16 16:36:19 -04:00
Kara Erickson cda9248b33 refactor(core): rename ngInjectorDef to ɵinj (#33151)
Injector defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngInjectorDef to inj. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

PR Close #33151
2019-10-16 16:36:19 -04:00
Miško Hevery d3f3d9b4cb test: Add script which allows running all of the profiling tests and compare results (#33186)
PR Close #33186
2019-10-16 10:22:30 -04:00
Kara Erickson fc93dafab1 refactor(core): rename ngModuleDef to ɵmod (#33142)
Module defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngModuleDef to mod. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

PR Close #33142
2019-10-14 23:08:10 +00:00
Kara Erickson d62eff7316 refactor(core): rename ngPipeDef to ɵpipe (#33142)
Pipe defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngPipeDef to pipe. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

PR Close #33142
2019-10-14 23:08:10 +00:00
Kara Erickson 0de2a5e408 refactor(core): rename ngFactoryDef to ɵfac (#33116)
Factory defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngFactoryDef to fac. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

Note that the other "defs" (ngPipeDef, etc) will be
prefixed and shortened in follow-up PRs, in an attempt to
limit how large and conflict-y this change is.

PR Close #33116
2019-10-14 20:27:25 +00:00
Kara Erickson 1a67d70bf8 refactor(core): rename ngDirectiveDef to ɵdir (#33110)
Directive defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngDirectiveDef to dir. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

Note that the other "defs" (ngFactoryDef, etc) will be
prefixed and shortened in follow-up PRs, in an attempt to
limit how large and conflict-y this change is.

PR Close #33110
2019-10-14 16:20:11 +00:00
Kara Erickson 64fd0d6db9 refactor(core): rename ngComponentDef to ɵcmp (#33088)
Component defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
`ngComponentDef` to `cmp`. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

Note that the other "defs" (ngDirectiveDef, etc) will be
prefixed and shortened in follow-up PRs, in an attempt to
limit how large and conflict-y this change is.

PR Close #33088
2019-10-11 15:45:22 -07:00
Matias Niemelä b2decf0266 perf(ivy): speed up bindings when no directives are present (#32919)
Prior to this fix, whenever a style or class binding is present, the
binding application process would require an instance of `TStylingContext`
to be built regardless of whether or not any binding resolution is needed
(just so that it knows whether or not there are any collisions).
This check is, however, unnecessary because if (and only if) there
are directives present on the element then are collisions possible.

This patch removes the need for style/class bindings to register
themselves on to a `TStylingContext` if there are no directives and
present on an element. This means that all map and prop-based
style/class bindings are applied as soon as bindings are updated on
an element.

PR Close #32919
2019-10-10 13:57:24 -07:00
Pawel Kozlowski 22d4efbed1 perf(ivy): introduce micro-benchmark for directive instantiation (#33082)
PR Close #33082
2019-10-10 13:56:52 -07:00
crisbeto 305f3686c3 build: fix compilation error in benchmark (#33067)
A PR that updates one of the benchmarks and another one that changes the signature for `elementStart` got in around the same time which is causing a compilation error. These changes fix the error.

PR Close #33067
2019-10-09 13:40:10 -07:00
crisbeto d5b87d32b0 perf(ivy): move attributes array into component def (#32798)
Currently Ivy stores the element attributes into an array above the component def and passes it into the relevant instructions, however the problem is that upon minification the array will get a unique name which won't compress very well. These changes move the attributes array into the component def and pass in the index into the instructions instead.

Before:
```
const _c0 = ['foo', 'bar'];

SomeComp.ngComponentDef = defineComponent({
  template: function() {
    element(0, 'div', _c0);
  }
});
```

After:
```
SomeComp.ngComponentDef = defineComponent({
  consts: [['foo', 'bar']],
  template: function() {
    element(0, 'div', 0);
  }
});
```

A couple of cases that this PR doesn't handle:
* Template references are still in a separate array.
* i18n attributes are still in a separate array.

PR Close #32798
2019-10-09 13:16:55 -07:00
Pawel Kozlowski affae99b22 perf(ivy): add static attributes to the element_text_create benchmark (#32997)
PR Close #32997
2019-10-08 13:02:11 -07:00
Pawel Kozlowski 8593d0d52e perf(ivy): increase number of created views in the element_text_create benchmark (#32979)
PR Close #32979
2019-10-04 11:44:57 -07:00
Matias Niemelä e668d7971d revert: feat(ivy): improve debugging experience for styles/classes (#32753) (#32841)
This reverts commit 32f4544f34.

PR Close #32841
2019-09-24 16:57:58 -07:00
Matias Niemelä 32f4544f34 feat(ivy): improve debugging experience for styles/classes (#32753)
This patch introduces the `printTable()` and `printSources()`
methods to `DebugStylingContext` which can be used via the
`window.ng.getDebugNode` helpers when debugging an application.

PR Close #32753
2019-09-24 10:37:42 -07:00
Matias Niemelä 0450f39625 refactor(ivy): move all styling util code into `utils/styling_utils.ts` (#32731)
PR Close #32731
2019-09-18 15:06:39 -07:00
Matias Niemelä ec0aa88f4e refactor(ivy): move `styling/instructions.ts` to `instructions/styling.ts` (#32731)
PR Close #32731
2019-09-18 15:06:39 -07:00
Matias Niemelä f88f717094 refactor(ivy): remame `styling_next` directory to `styling` (#32731)
PR Close #32731
2019-09-18 15:06:39 -07:00
Matias Niemelä 4f41473048 refactor(ivy): remove styling state storage and introduce direct style writing (#32591)
This patch is a final major refactor in styling Angular.

This PR includes three main fixes:

All temporary state taht is persisted between template style/class application
and style/class application in host bindings is now removed.
Removes the styling() and stylingApply() instructions.
Introduces a "direct apply" mode that is used apply prop-based
style/class in the event that there are no map-based bindings as
well as property collisions.

PR Close #32259

PR Close #32591
2019-09-16 14:12:48 -07:00
Pawel Kozlowski 1748aeb9c8 perf(ivy): convert all node-based benchmark to use a testing harness (#32699)
PR Close #32699
2019-09-16 09:31:15 -07:00
Misko Hevery 5a830c49cf refactor(ivy): improve micro-benchmark profiling (#32647)
PR Close #32647
2019-09-12 13:06:38 -07:00
cexbrayat 88c28ce208 refactor(ivy): migrate debug spec from render3 (#32621)
Migrate the remaining `render3/debug_spec.ts` to `acceptance`

PR Close #32621
2019-09-12 11:35:49 -07:00
cexbrayat e013aee636 refactor(ivy): migrate export spec from render3 (#32624)
The remaining test was using JS blocks and was already tested with `ngIf` in the existing acceptance test.

PR Close #32624
2019-09-12 11:33:03 -07:00
Pawel Kozlowski 024765b86a perf(ivy): introduce benchmark for listeners registration (#32495)
PR Close #32495
2019-09-12 10:27:44 -07:00
Pawel Kozlowski ea378a993a perf(ivy): binding update benchmark (#32574)
PR Close #32574
2019-09-12 06:30:08 -04:00
Matias Niemelä 53dbff66d7 revert: refactor(ivy): remove styling state storage and introduce direct style writing (#32259)
This reverts commit 15aeab1620.
2019-09-11 15:24:10 -07:00
Matias Niemelä 15aeab1620 refactor(ivy): remove styling state storage and introduce direct style writing (#32259) (#32596)
This patch is a final major refactor in styling Angular.

This PR includes three main fixes:

All temporary state taht is persisted between template style/class application
and style/class application in host bindings is now removed.
Removes the styling() and stylingApply() instructions.
Introduces a "direct apply" mode that is used apply prop-based
style/class in the event that there are no map-based bindings as
well as property collisions.

PR Close #32259

PR Close #32596
2019-09-11 16:27:10 -04:00
Matias Niemelä c84c27f7f4 revert: refactor(ivy): remove styling state storage and introduce direct style writing (#32259) 2019-09-10 18:08:05 -04:00
Matias Niemelä 3b37469735 refactor(ivy): remove styling state storage and introduce direct style writing (#32259)
This patch is a final major refactor in styling Angular.

This PR includes three main fixes:

All temporary state taht is persisted between template style/class application
and style/class application in host bindings is now removed.
Removes the styling() and stylingApply() instructions.
Introduces a "direct apply" mode that is used apply prop-based
style/class in the event that there are no map-based bindings as
well as property collisions.

PR Close #32259
2019-09-10 15:54:58 -04:00
cexbrayat f00bb85b58 refactor(ivy): migrate content spec from render3 (#32474)
Migrate the remaining `render3/content_spec.ts` to `acceptance` (some JS block ones were already migrated with `ngIf`).

PR Close #32474
2019-09-10 13:03:16 -04:00
cexbrayat ded57245e1 fix(ivy): match class and attribute value without case-sensitivity (#32548)
Prior to this commit, a directive with a selector `selector=".Titledir"` would not match an element like `div class="titleDir"` in Ivy whereas it would in VE. The same issue was present for `selector="[title=Titledir]` and `title="titleDir"`.  This fixes the Ivy behavior by changing the matching algorithm to use lowercased values.

Note that some `render3` tests needed to be changed to reflect that the compiler generates lowercase selectors. These tests are in the process to be migrated to `acceptance` to use `TestBed` in another PR anyway.

PR Close #32548
2019-09-10 06:31:22 -04:00
crisbeto 664e0015d4 perf(ivy): replace select instruction with advance (#32516)
Replaces the `select` instruction with a new one called `advance`. Instead of the jumping to a specific index, the new instruction goes forward X amount of elements. The advantage of doing this is that it should generate code the compresses better.

PR Close #32516
2019-09-10 06:30:28 -04:00
Pawel Kozlowski 2895edc9c6 perf(ivy): introduce a node-based micro-benchmarks harness (#32510)
PR Close #32510
2019-09-09 15:56:41 -04:00
cexbrayat c8b065524e refactor(ivy): cleanup di tests from render3 (#32165)
The tests were already migrated to acceptance with `ngFor`/`ngIf`, but were leftover in case JS blocks ended up supported in Ivy.

PR Close #32165
2019-08-30 12:49:04 -07:00
Pawel Kozlowski 8dc3f3647c perf(ivy): properly initialise global state in the element_text_create benchmark (#32397)
PR Close #32397
2019-08-30 12:42:28 -07:00
Matias Niemelä ba5e07efc7 perf(ivy): add a micro benchmark for map-based style and class bindings (#32401)
This patch introduces a new micro benchmark that performance tests
against map-based style and class bindings in Ivy running together
on the same element.

PR Close #32401
2019-08-30 13:52:35 -04:00
Matias Niemelä df8e6750a1 perf(ivy): add a micro benchmark for style and class bindings (#32401)
This patch introduces a new micro benchmark that performance tests
against style and class bindings in Ivy running together on the same
element.

PR Close #32401
2019-08-30 13:52:35 -04:00
Misko Hevery 8a47b48912 refactor: Move `dom_adapter.ts` to `@angular/common` (#32154)
This work is needed in preparation for turning tokens into tree-shakable injectables.

PR Close #32154
2019-08-29 21:51:56 -07:00
Pawel Kozlowski 5635505f2e refactor(ivy): remove unused ɵɵtextBinding instruction (#32345)
PR Close #32345
2019-08-28 21:37:15 -07:00
Carlos Ortiz García 3aba7ebe6a feat(core): Introduce TestBed.inject to replace TestBed.get (#32200)
TestBed.get is not type safe, fixing it would be a massive breaking
change. The Angular team has proposed replacing it with TestBed.inject
and deprecate TestBed.get.

Deprecation from TestBed.get will come as a separate commit.

Issue #26491
Fixes #29905

BREAKING CHANGE: Injector.get now accepts abstract classes to return
type-safe values. Previous implementation returned `any` through the
deprecated implementation.

PR Close #32200
2019-08-28 21:26:46 -07:00
Pawel Kozlowski 85864ed9f7 perf(ivy): add element and text creation benchmark (#32342)
PR Close #32342
2019-08-28 17:12:38 -07:00
Kristiyan Kostadinov c885178d5f refactor(ivy): move directive, component and pipe factories to ngFactoryFn (#31953)
Reworks the compiler to output the factories for directives, components and pipes under a new static field called `ngFactoryFn`, instead of the usual `factory` property in their respective defs. This should eventually allow us to inject any kind of decorated class (e.g. a pipe).

**Note:** these changes are the first part of the refactor and they don't include injectables. I decided to leave injectables for a follow-up PR, because there's some more cases we need to handle when it comes to their factories. Furthermore, directives, components and pipes make up most of the compiler output tests that need to be refactored and it'll make follow-up PRs easier to review if the tests are cleaned up now.

This is part of the larger refactor for FW-1468.

PR Close #31953
2019-08-27 13:57:00 -07:00
Pawel Kozlowski e63a7b0532 refactor(ivy): replace enter / leave view with selectView (#32263)
After a series of recent refactorings `enterView` and `leaveView` became
identical. This PR merges both into one concept of view selectio (similar
to a node selection). This reduces number of concepts and code size.

PR Close #32263
2019-08-26 13:18:28 -07:00
Kara Erickson cf4b944865 refactor(core): remove misc dom utils from DomAdapters (#32278)
PR Close #32278
2019-08-26 10:39:09 -07:00
Pawel Kozlowski 53bfa7c6d6 perf(ivy): improve NaN checks in change detection (#32212)
This commit drops our custom, change-detection specific, equality comparison util
in favour of the standard Object.is which has desired semantics.

There are multiple advantages of this approach:
- less code to maintain on our end;
- avoid NaN checks if both values are equal;
- re-write NaN checks so we don't trigger V8 deoptimizations.

PR Close #32212
2019-08-21 11:45:51 -07:00
Pawel Kozlowski 172bb76964 docs(ivy): update micro-benchmark instructions (#32190)
PR Close #32190
2019-08-19 10:10:39 -07:00
Miško Hevery 2e4d17f3a9 perf(core): make sanitization tree-shakable in Ivy mode (#31934)
In VE the `Sanitizer` is always available in `BrowserModule` because the VE retrieves it using injection.

In Ivy the injection is optional and we have instructions instead of component definition arrays. The implication of this is that in Ivy the instructions can pull in the sanitizer only when they are working with a property which is known to be unsafe. Because the Injection is optional this works even if no Sanitizer is present. So in Ivy we first use the sanitizer which is pulled in by the instruction, unless one is available through the `Injector` then we use that one instead.

This PR does few things:
1) It makes `Sanitizer` optional in Ivy.
2) It makes `DomSanitizer` tree shakable.
3) It aligns the semantics of Ivy `Sanitizer` with that of the Ivy sanitization rules.
4) It refactors `DomSanitizer` to use same functions as Ivy sanitization for consistency.

PR Close #31934
2019-08-15 10:30:12 -07:00
Pawel Kozlowski 253a1125bf test(ivy): add style binding node-based micro benchmark (#32104)
PR Close #32104
2019-08-15 09:55:03 -07:00