Skip to content

Commit

Permalink
Merge pull request #150 from angular/main
Browse files Browse the repository at this point in the history
Create a new pull request by comparing changes across two branches
  • Loading branch information
GulajavaMinistudio authored Nov 16, 2023
2 parents 3be2bfb + ec2d6e7 commit 5c85911
Show file tree
Hide file tree
Showing 32 changed files with 503 additions and 57 deletions.
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
<a name="17.1.0-next.0"></a>
# 17.1.0-next.0 (2023-11-15)
### compiler-cli
| Commit | Type | Description |
| -- | -- | -- |
| [56a76d73e0](https://github.com/angular/angular/commit/56a76d73e037aeea1975808d5c51608fd23d4fa6) | fix | modify `getConstructorDependencies` helper to work with reflection host after the previous change ([#52215](https://github.com/angular/angular/pull/52215)) |
### core
| Commit | Type | Description |
| -- | -- | -- |
| [94096c6ede](https://github.com/angular/angular/commit/94096c6ede67436a349ae07901f2bb418bf9f461) | feat | support TypeScript 5.3 ([#52572](https://github.com/angular/angular/pull/52572)) |
| [bdd61c768a](https://github.com/angular/angular/commit/bdd61c768a28b56c68634b99c036986499829f45) | fix | replace assertion with more intentional error ([#52234](https://github.com/angular/angular/pull/52234)) |
### router
| Commit | Type | Description |
| -- | -- | -- |
| [726530a9af](https://github.com/angular/angular/commit/726530a9af9c8daf7295cc3548f24e70f380d70e) | feat | Allow `onSameUrlNavigation: 'ignore'` in `navigateByUrl` ([#52265](https://github.com/angular/angular/pull/52265)) |

<!-- CHANGELOG SPLIT MARKER -->

<a name="17.0.3"></a>
# 17.0.3 (2023-11-15)
### animations
| Commit | Type | Description |
| -- | -- | -- |
| [f5872c9921](https://github.com/angular/angular/commit/f5872c992181a2c231890b83f92ec03ec9606802) | fix | prevent the AsyncAnimationRenderer from calling the delegate when there is no element. ([#52570](https://github.com/angular/angular/pull/52570)) |
### core
| Commit | Type | Description |
| -- | -- | -- |
| [6a1d4ed667](https://github.com/angular/angular/commit/6a1d4ed6670f5965a654e40997aa266a99925f50) | fix | handle non-container environment injector cases ([#52774](https://github.com/angular/angular/pull/52774)) |
| [5de7575be8](https://github.com/angular/angular/commit/5de7575be83b9829e65ad245034ee7ab1d966044) | fix | reset cached scope for components that were overridden using TestBed ([#52916](https://github.com/angular/angular/pull/52916)) |
### http
| Commit | Type | Description |
| -- | -- | -- |
| [7c066a4af4](https://github.com/angular/angular/commit/7c066a4af4faae25ee722c19576c63c3833066ee) | fix | Use the response `content-type` to set the blob `type`. ([#52840](https://github.com/angular/angular/pull/52840)) |
### migrations
| Commit | Type | Description |
| -- | -- | -- |
| [4e200bf13b](https://github.com/angular/angular/commit/4e200bf13b284fa89bbb0854cbb85dc8fe94d8bb) | fix | Add missing support for ngForOf ([#52903](https://github.com/angular/angular/pull/52903)) |
| [d033540d0f](https://github.com/angular/angular/commit/d033540d0f874a7a05b79c00e3151ed076fa71c3) | fix | Add support for bound versions of NgIfElse and NgIfThenElse ([#52869](https://github.com/angular/angular/pull/52869)) |
| [aa2d815648](https://github.com/angular/angular/commit/aa2d815648dbf3303cfe72bf976a4a87de406ee0) | fix | Add support for removing imports post migration ([#52763](https://github.com/angular/angular/pull/52763)) |
| [3831942771](https://github.com/angular/angular/commit/38319427711f4dab4e4d64ff48aecc7727085031) | fix | Fixes issue with multiple if elses with same template ([#52863](https://github.com/angular/angular/pull/52863)) |
| [e1f84a31dc](https://github.com/angular/angular/commit/e1f84a31dcac413251329c3b695a253234c6aae6) | fix | passed in paths will be respected in nx workspaces ([#52796](https://github.com/angular/angular/pull/52796)) |

<!-- CHANGELOG SPLIT MARKER -->

<a name="17.0.2"></a>
# 17.0.2 (2023-11-09)
### compiler-cli
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"short_name": "Angular DevTools",
"name": "Angular DevTools",
"description": "Angular DevTools extends Chrome DevTools adding Angular specific debugging and profiling capabilities.",
"version": "1.0.8",
"version_name": "1.0.8",
"version": "1.0.9",
"version_name": "1.0.9",
"minimum_chrome_version": "102",
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"short_name": "Angular DevTools",
"name": "Angular DevTools",
"description": "Angular DevTools extends Firefox DevTools adding Angular specific debugging and profiling capabilities.",
"version": "1.0.8",
"version": "1.0.9",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"icons": {
"16": "assets/icon16.png",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function MyApp_Template(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵrepeater(2, ctx.items);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function MyApp_Template(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵrepeater(2, ctx.items);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function MyApp_Template(rf, ctx) {
$r3$.ɵɵtemplate(4, MyApp_ng_template_4_Template, 0, 0, "ng-template");
}
if (rf & 2) {
$r3$.ɵɵrepeater(1, ctx.items);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ function MyApp_Template(rf, ctx) {
$r3$.ɵɵrepeaterCreate(2, MyApp_For_3_Template, 1, 1, null, null, $_forTrack0$, true);
}
if (rf & 2) {
$r3$.ɵɵrepeater(0, ctx.items);
$r3$.ɵɵrepeater(2, ctx.otherItems);
$r3$.ɵɵrepeater(ctx.items);
$r3$.ɵɵadvance(2);
$r3$.ɵɵrepeater(ctx.otherItems);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function MyApp_Template(rf, ctx) {
$r3$.ɵɵrepeaterCreate(2, MyApp_For_3_Template, 1, 1, null, null, $_forTrack0$);
}
if (rf & 2) {
$r3$.ɵɵrepeater(0, ctx.items);
$r3$.ɵɵrepeater(2, ctx.otherItems);
$r3$.ɵɵrepeater(ctx.items);
$r3$.ɵɵadvance(2);
$r3$.ɵɵrepeater(ctx.otherItems);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function MyApp_Template(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵrepeater(2, ctx.items);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ function MyApp_Template(rf, ctx) {
}
if (rf & 2) {
$r3$.ɵɵtextInterpolate4(" ", ctx.$index, " ", ctx.$count, " ", ctx.$first, " ", ctx.$last, " ");
$r3$.ɵɵrepeater(1, ctx.items);
$r3$.ɵɵadvance(3);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
$r3$.ɵɵadvance(2);
$r3$.ɵɵtextInterpolate4(" ", ctx.$index, " ", ctx.$count, " ", ctx.$first, " ", ctx.$last, " ");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function MyApp_Template(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵrepeater(2, ctx.items);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function MyApp_Template(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵrepeater(2, ctx.items);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function MyApp_Template(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵrepeater(2, ctx.items);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ function MyApp_Template(rf, ctx) {
$r3$.ɵɵrepeaterCreate(0, MyApp_For_1_Template, 1, 1, null, null, $_forTrack0$, true);
}
if (rf & 2) {
$r3$.ɵɵrepeater(0, ctx.items);
$r3$.ɵɵrepeater(ctx.items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function MyApp_Template(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵrepeater(2, ctx.items);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function MyApp_Template(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵrepeater(2, $r3$.ɵɵpipeBind1(4, 1, ctx.items));
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater($r3$.ɵɵpipeBind1(4, 1, ctx.items));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function MyApp_For_3_Template(rf, ctx) {
if (rf & 2) {
const $item_r1$ = ctx.$implicit;
$r3$.ɵɵtextInterpolate1(" ", $item_r1$.name, " ");
$r3$.ɵɵrepeater(1, $item_r1$.subItems);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater($item_r1$.subItems);
}
}
Expand All @@ -31,6 +32,7 @@ function MyApp_Template(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵrepeater(2, ctx.items);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function MyApp_For_3_Template(rf, ctx) {
if (rf & 2) {
const $item_r1$ = ctx.$implicit;
$r3$.ɵɵtextInterpolate1(" ", $item_r1$.name, " ");
$r3$.ɵɵrepeater(1, $item_r1$.subItems);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater($item_r1$.subItems);
}
}
Expand All @@ -31,6 +32,7 @@ function MyApp_Template(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵrepeater(2, ctx.items);
$r3$.ɵɵadvance(1);
$r3$.ɵɵrepeater(ctx.items);
}
}
7 changes: 3 additions & 4 deletions packages/compiler/src/render3/view/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1574,10 +1574,9 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
// because its value isn't stored in the LView.
const value = block.expression.visit(this._valueConverter);

// `repeater(0, iterable)`
this.updateInstruction(
block.sourceSpan, R3.repeater,
() => [o.literal(blockIndex), this.convertPropertyBinding(value)]);
// `advance(x); repeater(iterable)`
this.updateInstructionWithAdvance(
blockIndex, block.sourceSpan, R3.repeater, () => [this.convertPropertyBinding(value)]);
}

private registerComputedLoopVariables(block: t.ForLoopBlock, bindingScope: BindingScope): void {
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler/src/template/pipeline/ir/src/ops/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ export function createConditionalOp(
};
}

export interface RepeaterOp extends Op<UpdateOp> {
export interface RepeaterOp extends Op<UpdateOp>, DependsOnSlotContextOpTrait {
kind: OpKind.Repeater;

/**
Expand Down Expand Up @@ -562,6 +562,7 @@ export function createRepeaterOp(
collection,
sourceSpan,
...NEW_OP,
...TRAIT_DEPENDS_ON_SLOT_CONTEXT,
};
}

Expand Down
5 changes: 2 additions & 3 deletions packages/compiler/src/template/pipeline/src/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,8 @@ export function repeaterCreate(
return call(Identifiers.repeaterCreate, args, sourceSpan);
}

export function repeater(
metadataSlot: number, collection: o.Expression, sourceSpan: ParseSourceSpan|null): ir.UpdateOp {
return call(Identifiers.repeater, [o.literal(metadataSlot), collection], sourceSpan);
export function repeater(collection: o.Expression, sourceSpan: ParseSourceSpan|null): ir.UpdateOp {
return call(Identifiers.repeater, [collection], sourceSpan);
}

export function deferWhen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ function reifyUpdateOperations(_unit: CompilationUnit, ops: ir.OpList<ir.UpdateO
op, ng.conditional(op.targetSlot.slot, op.processed, op.contextValue, op.sourceSpan));
break;
case ir.OpKind.Repeater:
ir.OpList.replace(op, ng.repeater(op.targetSlot.slot!, op.collection, op.sourceSpan));
ir.OpList.replace(op, ng.repeater(op.collection, op.sourceSpan));
break;
case ir.OpKind.DeferWhen:
ir.OpList.replace(op, ng.deferWhen(op.prefetch, op.expr, op.sourceSpan));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import {ElementCollector, ElementToMigrate, MigrateError, Result} from './types'
import {calculateNesting, getMainBlock, getOriginals, hasLineBreaks, parseTemplate, reduceNestingOffset} from './util';

export const ngfor = '*ngFor';
export const nakedngfor = 'ngFor';
const fors = [
ngfor,
nakedngfor,
];

export const commaSeparatedSyntax = new Map([
['(', ')'],
['{', '}'],
Expand All @@ -34,7 +40,7 @@ export function migrateFor(template: string): {migrated: string, errors: Migrate
}

let result = template;
const visitor = new ElementCollector([ngfor]);
const visitor = new ElementCollector(fors);
visitAll(visitor, parsed.rootNodes);
calculateNesting(visitor, hasLineBreaks(template));

Expand Down Expand Up @@ -65,8 +71,14 @@ export function migrateFor(template: string): {migrated: string, errors: Migrate
return {migrated: result, errors};
}


function migrateNgFor(etm: ElementToMigrate, tmpl: string, offset: number): Result {
if (etm.forAttrs !== undefined) {
return migrateBoundNgFor(etm, tmpl, offset);
}
return migrateStandardNgFor(etm, tmpl, offset);
}

function migrateStandardNgFor(etm: ElementToMigrate, tmpl: string, offset: number): Result {
const aliasWithEqualRegexp = /=\s*(count|index|first|last|even|odd)/gm;
const aliasWithAsRegexp = /(count|index|first|last|even|odd)\s+as/gm;
const aliases = [];
Expand Down Expand Up @@ -136,6 +148,43 @@ function migrateNgFor(etm: ElementToMigrate, tmpl: string, offset: number): Resu
return {tmpl: updatedTmpl, offsets: {pre, post}};
}

function migrateBoundNgFor(etm: ElementToMigrate, tmpl: string, offset: number): Result {
const forAttrs = etm.forAttrs!;
const aliasMap = forAttrs.aliases;

const originals = getOriginals(etm, tmpl, offset);
const condition = `${forAttrs.item} of ${forAttrs.forOf}`;

const aliases = [];
let aliasedIndex = '$index';
for (const [key, val] of aliasMap) {
aliases.push(` let ${key.trim()} = $${val}`);
if (val.trim() === 'index') {
aliasedIndex = key;
}
}
const aliasStr = (aliases.length > 0) ? `;${aliases.join(';')}` : '';

let trackBy = forAttrs.item;
if (forAttrs.trackBy !== '') {
// build trackby value
trackBy = `${forAttrs.trackBy.trim()}(${aliasedIndex}, ${forAttrs.item})`;
}

const {start, middle, end} = getMainBlock(etm, tmpl, offset);
const startBlock = `@for (${condition}; track ${trackBy}${aliasStr}) {\n ${start}`;

const endBlock = `${end}\n}`;
const forBlock = startBlock + middle + endBlock;

const updatedTmpl = tmpl.slice(0, etm.start(offset)) + forBlock + tmpl.slice(etm.end(offset));

const pre = originals.start.length - startBlock.length;
const post = originals.end.length - endBlock.length;

return {tmpl: updatedTmpl, offsets: {pre, post}};
}

function getNgForParts(expression: string): string[] {
const parts: string[] = [];
const commaSeparatedStack: string[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ngif = '*ngIf';
export const boundngif = '[ngIf]';
export const nakedngif = 'ngIf';

export const ifs = [
const ifs = [
ngif,
nakedngif,
boundngif,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const nakedcase = 'ngSwitchCase';
export const switchdefault = '*ngSwitchDefault';
export const nakeddefault = 'ngSwitchDefault';

export const switches = [
const switches = [
ngswitch,
boundcase,
switchcase,
Expand Down
Loading

0 comments on commit 5c85911

Please sign in to comment.