Handle some cases which would previously result in broken code.
- Importing bootstrap.dart deferred
- Using combinators when importing bootstrap.dart
- Importing bootstrap.dart with a prefix
Closes#6749
Previously, we generated the code to initialize the reflector into the
<file>.ng_deps.dart and the compiled template and change detector code
into <file>.template.dart.
Update the transformer to generate all code into <file>.template.dart to
avoid the additional HTTP requests necessary when debugging
applications in Dartium.
BEFORE:
The following would throw in the dev mode because `f` would return a new array when called by checkNoChanges.
@Component({
template: `
{{f()}}
`
})
class A {
f() { return [1]; }
}
AFTER:
The checkNoChanges function compares only primitives types for equality, and deeply compares iterables. Other objects cannot cause checkNoChanges to throw. This means that the dev mode would never fail given a legal program, but may allow some illegal programs.
Previously, template codegen was done asynchronously, which could result
in reflector state being overwritten and leading to compile errors.
Update the codegen to run synchronously to ensure this does not happen.
Closes#6603
Adds tests for public Dart and TS frameworks to make sure that
components with templateUrl can be created by the TestComponentBuilder.
Closes#6359Closes#6601
Resolve all invalid field override errors, workaround current
reflection limitations in Dart Dev Compiler. todo, hello_world and
key_events samples now work with Dart Dev Compiler.
BREAKING CHANGE: remove TemplateRef.elementRef setter
Closes#6441
Widen version dependencies for `package:angular`, `package:code_transformers`,
and `package:observe`.
`package:guinness` uses `package:unittest` while
the newest versions of `package:code_transformers` use `package:test`.
This causes our end-to-end Dart transformer tests (which use testing
code in `package:code_transformers`) to be skipped.
To fix this:
- Move e2e tests to run in a separate file
- Run `gulp test.server.dart` tests serially
Closes#5922Closes#5935
Replace uses of `package:code_transformers`, which is only used to
convert from uri to `AssetId`, with calls to the utility methods in
`src/transform/common/url_resolver.dart`.
Closes#5931
With providers split into bundles, the test injector is now able to
use providers for a given bundle. Suggested provider lists for tests are
available in `angular2/platform/testing/<platform>`.
Change the providers for a test suite using `setBaseTestProviders`. This
should be done once at the start of the test suite, before any test cases
run.
BREAKING CHANGE: Tests are now required to use `setBaseTestProviders`
to set up. Assuming your tests are run on a browser, setup would change
as follows.
Before:
```js
// Somewhere in test setup
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
BrowserDomAdapter.makeCurrent
```
After:
```js
// Somewhere in the test setup
import {setBaseTestProviders} from 'angular2/testing';
import {
TEST_BROWSER_PLATFORM_PROVIDERS,
TEST_BROWSER_APPLICATION_PROVIDERS
} from 'angular2/platform/testing/browser';
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS,
TEST_BROWSER_APPLICATION_PROVIDERS);
```
Closes#5351, Closes#5585Closes#5975
In the `TemplateCompiler` phase, avoid reading in the `.ng_meta.json` files of
imported libraries when we can determine that the file we are processing
does not define any `View`s.
Closes#6183
BREAKING CHANGE:
- Platform pipes can only contain types and arrays of types,
but no bindings any more.
- When using transformers, platform pipes need to be specified explicitly
in the pubspec.yaml via the new config option
`platform_pipes`.
- `Compiler.compileInHost` now returns a `HostViewFactoryRef`
- Component view is not yet created when component constructor is called.
-> use `onInit` lifecycle callback to access the view of a component
- `ViewRef#setLocal` has been moved to new type `EmbeddedViewRef`
- `internalView` is gone, use `EmbeddedViewRef.rootNodes` to access
the root nodes of an embedded view
- `renderer.setElementProperty`, `..setElementStyle`, `..setElementAttribute` now
take a native element instead of an ElementRef
- `Renderer` interface now operates on plain native nodes,
instead of `RenderElementRef`s or `RenderViewRef`s
Closes#5993
Before, all test framework wrappers (internal for dart and js/ts,
angular2_test for dart and testing for js/ts) had similar logic to
keep track of current global test injector and test provider list.
This change wraps that logic into one class managed by the test
injector.
Closes#5920
Before, all test framework wrappers (internal for dart and js/ts,
angular2_test for dart and testing for js/ts) had similar logic to
keep track of current global test injector and test provider list.
This change wraps that logic into one class managed by the test
injector.
Closes#5819
BREAKING CHANGE:
`<whatever />` used to be expanded to `<whatever></whatever>`.
The parser now follows the HTML5 spec more closely.
Only void and foreign elements can be self closed.
Closes#5591
angular2_testing is a user-facing dart test library built on top of
the package:test dart unittest framework and runner. For usage,
see modules_dart/angular2_testing/README.md.
Closes#3289
BREAKING CHANGE:
Previously, components that would implement lifecycle interfaces would include methods
like "onChanges" or "afterViewInit." Given that components were at risk of using such
names without realizing that Angular would call the methods at different points of
the component lifecycle. This change adds an "ng" prefix to all lifecycle hook methods,
far reducing the risk of an accidental name collision.
To fix, just rename these methods:
* onInit
* onDestroy
* doCheck
* onChanges
* afterContentInit
* afterContentChecked
* afterViewInit
* afterViewChecked
* _Router Hooks_
* onActivate
* onReuse
* onDeactivate
* canReuse
* canDeactivate
To:
* ngOnInit,
* ngOnDestroy,
* ngDoCheck,
* ngOnChanges,
* ngAfterContentInit,
* ngAfterContentChecked,
* ngAfterViewInit,
* ngAfterViewChecked
* _Router Hooks_
* routerOnActivate
* routerOnReuse
* routerOnDeactivate
* routerCanReuse
* routerCanDeactivate
The names of lifecycle interfaces and enums have not changed, though interfaces
have been updated to reflect the new method names.
Closes#5036
Import dependencies from `angular2/angular2.dart` in `hello_world` to
ensure that any size regressions are caught by our checks.
Update to avoid regressions like #5419.
Closes#5394
This make apps to load quicker with pub serve (only builds what is
needed).
Note that lazy transformers seem to make pub build slower, so we wrap
transformers to force them to be eager in release mode.
Closes#5372
All common directives, forms, and pipes have been moved out of angular2/core,
but we kept reexporting them to make transition easier.
This commit removes the reexports.
BREAKING CHANGE
Before
import {NgIf} from 'angular2/core';
After
import {NgIf} from 'angular2/common';
Closes#5362
Currently, core depends on DomRenderer, which depends on the browser.
This means that if you depend on angular2/core, you will always
pull in the browser dom adapter and the browser render, regardless
if you need them or not.
This PR moves the browser dom adapter and the browser renderer out of core.
BREAKING CHANGE
If you import browser adapter or dom renderer directly (not via angular2/core),
you will have to change the import path.
Fix @Input annotations to work with setter methods in dart, and fix @Output
annotations to work with getter methods in Dart when using transformers.
Closes#5251Closes#5259
After discussing it we decided that PLATFORM_ is a better prefix for directives available everywhere in the app.
BREAKING CHANGE
AMBIENT_DIRECTIVES -> PLATFORM_DIRECTIVES
AMBIENT_PIPES -> PLATFORM_PIPES
Closes#5201
This is part of ongoing work to make core platform-independent.
BREAKING CHANGE
All private exports from 'angular2/src/core/facade/{lang,collection,exception_handler}' should be replaced with 'angular2/src/facade/{lang,collection,exception_handler}'.
BREAKING CHANGE
All private exports from 'angular2/src/core/{directives,pipes,forms}' should be replaced with 'angular2/src/common/{directives,pipes,formis}'
Closes#5153
Store dependency import information in a dedicated list in `NgDepsModel`
rather than as a boolean field on `ImportModel`. An `ImportModel` should
not "care" whether it is a .ng_deps.dart import or not -- this
information belongs in `NgDepsModel`.
This simplifies some of the logic around how `NgDepsModel` imports are
processed and eventually output.
- Move zone-related code out of logger.dart and into zone.dart.
- Rename `logger` => `log`.
- Add the ability to specify a zone-local `TemplateCompiler`.
The template compiler update removed the option to run the transformer
without generating change detectors and deprecated the
`generate_change_detectors` transformer parameter.
Now that it has been deprecated for several weeks, remove it from the
transformer code.
Forward `reflectPropertiesAsAttributes` => `reflect_properties_as_attributes`
and add a deprecation warning to `reflectPropertiesAsAttributes`.
Closes#4433
- Changes the `alreadyChecked` flag of AbstractChangeDetector to a new `state` flag.
- Changes all checks of alreadyChecked to check that the state is NeverChecked.
- Set state to Errored if an error is thrown during detection.
- Skip change detection for a detector and its children when the state is Errored.
- Add a test to validate this fixes issue #4323.
Closes#4953
Match [ViewResolver][]'s semantics for reading template and style values
from `@Component` and `@View` annotations.
We now warn if template and/or style values appear on an `@Component`
annotation and a `@View` annotation is present.
[ViewResolver]: 7c6130c2c5/modules/angular2/src/core/linker/view_resolver.ts
Previously, importing a library twice using different prefixes could
cause the template compiler step to incorrect omit `Directive`
dependencies provided by that library.
Previously, we parsed dependencies out of a the stringified value of
`directives`, which is brittle and error-prone.
Move this parsing into `DirectiveProcessor` where we have the full Dart
ast to help.
Previously, `DeferredRewriter` checked for the existence of
`.ng_deps.dart` files to determine which deferred libraries it needed to
rewrite, requiring that those assets exist at the time it was run.
Update to check for `.ng_meta.json` files instead, which exist after the
`DirectiveProcessor` phase. This allows the `DeferredRewriter` (which
only processes *.dart files) to run in
parallel with `TemplateComplier` (which only processes *.ng_meta.json
files) and `StylesheetCompiler` (which only processes *.css files).
Have DeferredRewriter to check existence of .ng_meta.json assets rather than .ng_deps.dart assets
Update `DirectiveProcessor` and `TemplateCompiler` to generate the
getters, setters, and methods currently generated in `BindGenerator`.
Update `DirectiveMetadataLinker` to output `.ng_meta.json` files instead
of `.ng_deps.dart` files, avoiding full codegen until the last phase.
This allows us to dedupe codegen logic and remove an additional phase
from the transformer.
The directory contains code authored in a style that makes it transpilable to dart. As such, these are not idiomatic examples of Angular 2 usage.
The main purpose of this directory is to enable experimentation with Angular within the angular/angular repository.
Closes#4342Closes#4639
Now that we can specify `directives` in either `@View` or `@Component`,
we will try to parse from both.
Previously, we would trash any `directives` parsed in the first
annotation upon encountering the second annotation. This ensures that we
maintain that list of `directives` regardless of annotation ordering.
Handle the situation where a `.dart` file generates a `.ng_meta.json`
file but does not register any reflective information.
An example of this would be a file that defines a const list that looks
like a directive alias. The transformer keeps track of this, and creates
a `.ng_meta.json` file but never creates a `.ng_deps.dart` file, which
can result in other files being linked to it and it not defining an
`initReflector` method.
`DeferredRewriter` depends on the presence of `.ng_deps.dart` files,
which do not yet exist in the phase where it was previously run.
Update the transformer phases to fix this and add an integration test to
prevent regression.
Link `NgDeps` & `NgMeta` data in the same phase to avoid unnecessary asset
creation & reading.
Remove `NgMeta#exports` and instead use `NgDeps#exports` to link `NgMeta` files
in `ng_meta_linker.dart`.
Previously, annotations which were const objects (as opposed to const
instance creation expressions) were incorrectly output as instance
creation expressions.
Before:
```
const override() // A const instance creation expression
```
After
```
override // A const instance
```
Closes#4481