-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundle todo #23168
Bundle todo #23168
Conversation
@@ -71,10 +71,14 @@ export function compileDirective( | |||
|
|||
// e.g. `attributes: ['role', 'listbox']` | |||
field('attributes', createHostAttributesArray(directive, outputCtx)); | |||
console.error('=======', directive); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/* These tests are codified version of the tests in compiler_canonical_spec.ts. Every | ||
* test in compiler_canonical_spec.ts should have a corresponding test here. | ||
*/ | ||
fdescribe('compiler compliance: listen()', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fdescribe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
## Compiler | ||
- [ ] Remove ` tslib_1.__decorate([core_1.Input(), tslib_1.__metadata("design:type", Object)], TodoComponent.prototype, "todo", void 0);` from generated output. | ||
|
||
- [ ] Allow compilation of `@angular/common` through ivy. | ||
|
||
## Ivy Runtime | ||
- [ ] Work on `ViewContainerRef` needs to cause change detection so that `todo` app renders correctly on first render. | ||
- [ ] The todo input value box is not correctly rendering to checked for completed tasks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fixed by #23161, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -1765,7 +1765,7 @@ export function wrapListenerWithDirtyLogic(view: LView, listenerFn: (e?: any) => | |||
*/ | |||
export function wrapListenerWithDirtyAndDefault( | |||
view: LView, listenerFn: (e?: any) => any): EventListener { | |||
return function(e: Event) { | |||
return function wrapListenerIn_markViewDirty(e: Event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow CS wrapListenerInMarkViewDirty
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to keep this as is unless you feel strongly. Rest of the generated code follows this convention such as ToDoAppComponent_NgIf_NgForOf_NgIf_Template_6
return null; | ||
} | ||
|
||
function createOutputsObject( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
factorize createInputsObject
/ createOutputsObject
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored
}) | ||
export class MyComponent { | ||
@Input() name; | ||
@Input('renamed') original; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Input() input;
@Input('renamedInput') originalInput;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleaned up
selector: '[my-directive]', | ||
}) | ||
export class MyDirective { | ||
@Input() dirName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as for the cmp: consistency for I vs O names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
import {compile, expectEmit} from './mock_compile'; | ||
|
||
/* These tests are codified version of the tests in compiler_canonical_spec.ts. Every | ||
* test in compiler_canonical_spec.ts should have a corresponding test here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it the case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed comment
Commit message typo -> "statmentes" (es) -> "statements" (en) |
const template = ` | ||
template:function MyComponent_Template(ctx:any,cm:boolean){ | ||
if (cm) { | ||
i0.ɵC(0,MyComponent_NgForOf_Template_0,null,_c0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MyComponent_NgForOf_Template_0
, _c0
, i0
, ... should not be hardcoded
use IDENT
or $matchingName$
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
import {MockDirectory, setup} from '../aot/test_util'; | ||
import {compile, expectEmit} from './mock_compile'; | ||
|
||
/* These tests are codified version of the tests in compiler_canonical_spec.ts. Every |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not the case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline comments in each commits
if (cm) { | ||
i0.ɵE(0,'div'); | ||
i0.ɵL('click',function MyComponent_NgForOf_NgForOf_NgForOf_Template_1_div_click_listener($event:any){ | ||
const pd_b:any = ((<any>ctx.onClick($_r0$,$_r1$,$_r2$)) !== false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generated code doesn't match our canonical spec for listeners here. Is there a reason for that or is this just work that hasn't been done yet in the compiler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should convert the canonical specs to this format. Out of scope for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the generated code to match spec. It is a bit of a hack so please let take a look if you are OK with it.
Hi @mhevery! This PR has merge conflicts due to recent upstream merges. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
You can preview 4560326 at https://pr23168-4560326.ngbuilds.io/. |
You can preview 4579242 at https://pr23168-4579242.ngbuilds.io/. |
function noop() {} | ||
|
||
/** | ||
* Function which is executed whenever a variable is refferenced for the first time in a given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
referenced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
* - value `lhs` is the left hand side which is an AST representing `abc` which | ||
* can be used in other places of the source code. | ||
* - value `rhs` is the right hand side which is an AST representing `a.b.c` which | ||
* can be used in other places of the source code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure to understand "which can be used in other places of the source code." ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a left over from previous behavior. I have removed it and I think it makes it clearer.
|
||
// The template should look like this (where IDENT is a wild card for an identifier): | ||
const template = ` | ||
static ngComponentDef = i0.ɵdefineComponent({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i0
should not be hardcoded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to IDENT
} | ||
}; | ||
|
||
// The template should look like this (where IDENT is a wild card for an identifier): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no IDENT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now there is
@@ -0,0 +1,86 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a conformance test ? should it be moved to that folder ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you think it is conformance. I think of it as unit test for the r3_view_compiler.ts
but that test file is huge so i suffixed it by type intpu_outputs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you think it is conformance
Because the only assertion you have here is about the compiler output.
Probably we should have a clear definition of the types of test and what they should do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed in person
@@ -193,7 +196,10 @@ export function compileComponent( | |||
} | |||
|
|||
// e.g `inputs: {a: 'a'}` | |||
field('inputs', createInputsObject(component, outputCtx)); | |||
field('inputs', createMapObjectLiteral(component.inputs, outputCtx)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other fields are defined only when they should (ie features
, directives
, pipes
, ...).
Should we do the same for inputs
and outputs
?
It would be better for code size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed in person, it is OK.
set title(value: string) { this._title = value.trim(); } | ||
|
||
constructor(title: string, completed: boolean = false) { | ||
this.completed = completed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public completed = false
in the args ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixe
constructor(title: string, completed: boolean = false) { | ||
this.completed = completed; | ||
this.editing = false; | ||
this.title = title.trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to trim here (done in the setter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
Given ``` <div *ngFor=”…” (click)=“doSomething()”> ``` Before `doSomething` would execute on the inner template context, which is incorrect. The correct behavior is to execute on the top level context of the component.
When compiling templates the compiler would often bind to closest context rather than the component context. The only time one should be binding to the cont component is in explicit cases where the inner template declares local variable.
You can preview 2311600 at https://pr23168-2311600.ngbuilds.io/. |
You can preview f2e55de at https://pr23168-f2e55de.ngbuilds.io/. |
Given ``` <div *ngFor=”…” (click)=“doSomething()”> ``` Before `doSomething` would execute on the inner template context, which is incorrect. The correct behavior is to execute on the top level context of the component. PR Close #23168
When compiling templates the compiler would often bind to closest context rather than the component context. The only time one should be binding to the cont component is in explicit cases where the inner template declares local variable. PR Close #23168
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information