Skip to content

Commit

Permalink
Merge pull request #136 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 Oct 17, 2023
2 parents e5b2204 + 7466004 commit af352fd
Show file tree
Hide file tree
Showing 51 changed files with 669 additions and 219 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
migrating from the previously used ==. NgSwitch expressions and / or
individual condition values need adjusting to this stricter equality
check. The added warning message should help pinpointing NgSwitch
usages where adjustements are needed.
usages where adjustments are needed.
### core
- The `mutate` method was removed from the `WritableSignal` interface and completely
dropped from the public API surface. As an alternative please use the update method and
Expand Down
2 changes: 1 addition & 1 deletion aio/content/guide/esbuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Avoiding the use of modules with non-local side effects (outside of polyfills) i

### Long build times when using Sass combined with pnpm or yarn PnP

Applications may have increased build times due to the need to workaround Sass resolution incompabilities when using either the pnpm or Yarn PnP package managers.
Applications may have increased build times due to the need to workaround Sass resolution incompatibilities when using either the pnpm or Yarn PnP package managers.
Sass files with `@import` or `@use` directives referencing a package when using either of these package managers can trigger the performance problem.

An alternative workaround that alleviates the build time increases is in development and will be available before the build system moves to stable status.
Expand Down
27 changes: 26 additions & 1 deletion aio/content/guide/language-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,31 @@ This lets the Angular Language Service provide diagnostics and completions in `.

Either directly install the "Eclipse IDE for Web and JavaScript developers" package which comes with the Angular Language Server included, or from other Eclipse IDE packages, use Help > Eclipse Marketplace to find and install [Eclipse Wild Web Developer](https://marketplace.eclipse.org/content/wild-web-developer-html-css-javascript-typescript-nodejs-angular-json-yaml-kubernetes-xml).

### Neovim

1. [Setup coc.nvim](https://github.com/neoclide/coc.nvim)

2. [Configure the Angular Language Service](https://github.com/iamcco/coc-angular/issues/70#issuecomment-1616340751)

```
{
"languageserver": {
"angular": {
"command": "ngserver",
"args": [
"--stdio",
"--tsProbeLocations",
"/usr/local/lib/node_modules/typescript/lib",
"--ngProbeLocations",
"/usr/local/lib/node_modules/@angular/language-server/bin"
],
"filetypes": ["ts", "typescript", "html"],
"trace.server.verbosity": "verbose"
}
}
}
```

## How the Language Service works

When you use an editor with a language service, the editor starts a separate language-service process and communicates with it through an [RPC](https://en.wikipedia.org/wiki/Remote_procedure_call), using the [Language Server Protocol](https://microsoft.github.io/language-server-protocol).
Expand Down Expand Up @@ -168,4 +193,4 @@ The Angular Language Services then looks at `data.---` within its context, asks

<!-- end links -->

@reviewed 2022-02-28
@reviewed 2022-02-28
4 changes: 4 additions & 0 deletions aio/content/tutorial/tour-of-heroes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,8 @@ Here's the application in action:

</div>

## Next steps

* [Create a new project](tutorial/tour-of-heroes/toh-pt0)

@reviewed 2022-05-16
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
"verifyUniqueConsts"
]
}
],
"skipForTemplatePipeline": true
]
},
{
"description": "should support named interpolations",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
"verifyUniqueConsts"
]
}
],
"skipForTemplatePipeline": true
]
},
{
"description": "should work with ICUs",
Expand All @@ -95,13 +94,19 @@
],
"expectations": [
{
"files": [
{
"generated": "self_closing_tags.js",
"expected": "self_closing_tags.template.js",
"templatePipelineExpected": "self_closing_tags.pipeline.js"
}
],
"extraChecks": [
"verifyPlaceholdersIntegrity",
"verifyUniqueConsts"
]
}
],
"skipForTemplatePipeline": true
]
},
{
"description": "should not emit duplicate i18n consts for nested <ng-container>s",
Expand All @@ -127,8 +132,7 @@
"verifyUniqueConsts"
]
}
],
"skipForTemplatePipeline": true
]
},
{
"description": "should generate a self-closing container instruction for ng-container inside i18n",
Expand All @@ -142,8 +146,7 @@
"verifyUniqueConsts"
]
}
],
"skipForTemplatePipeline": true
]
},
{
"description": "should not generate a self-closing container instruction for ng-container with non-text ",
Expand All @@ -166,13 +169,19 @@
],
"expectations": [
{
"files": [
{
"generated": "structural_directives.js",
"expected": "structural_directives.template.js",
"templatePipelineExpected": "structural_directives.pipeline.js"
}
],
"extraChecks": [
"verifyPlaceholdersIntegrity",
"verifyUniqueConsts"
]
}
],
"skipForTemplatePipeline": true
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function MyComponent_ng_template_3_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵi18nStart(0, 1);
$r3$.ɵɵelement(1, "img", 2);
$r3$.ɵɵi18nEnd();
}
}
consts: () => {
__i18nMsg__('{$tagImg} is my logo #1 ', [['tagImg', String.raw`\uFFFD#2\uFFFD\uFFFD/#2\uFFFD`]], {original_code: {tagImg: '<img src="logo.png" title="Logo" />'}}, {})
__i18nMsg__('{$tagImg} is my logo #2 ', [['tagImg', String.raw`\uFFFD#1\uFFFD\uFFFD/#1\uFFFD`]], {original_code: {tagImg: '<img src="logo.png" title="Logo" />'}}, {})
return [
$i18n_0$,
$i18n_1$,
["src", "logo.png", "title", "Logo"]
];
},
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementContainerStart(0);
$r3$.ɵɵi18nStart(1, 0);
$r3$.ɵɵelement(2, "img", 2);
$r3$.ɵɵi18nEnd();
$r3$.ɵɵelementContainerEnd();
$r3$.ɵɵtemplate(3, MyComponent_ng_template_3_Template, 2, 0, "ng-template");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// NOTE: applying structural directives to <ng-template> is typically user error, but it is technically allowed, so we need to support it.
function MyComponent_0_ng_template_0_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵi18n(0, 0);
}
}
function MyComponent_0_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵtemplate(0, MyComponent_0_ng_template_0_Template, 1, 0, "ng-template");
}
}
function MyComponent_ng_container_1_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementContainerStart(0);
$r3$.ɵɵi18n(1, 1);
$r3$.ɵɵelementContainerEnd();
}
}
decls: 2,
vars: 2,
consts: () => {
__i18nMsg__('Content A', [], {}, {})
__i18nMsg__('Content B', [], {}, {})
return [
$i18n_0$,
$i18n_1$,
[__AttributeMarker.Template__, "ngIf"]
];
},
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵtemplate(0, MyComponent_0_Template, 1, 0, null, 2)(1, MyComponent_ng_container_1_Template, 2, 0, "ng-container", 2);
}
if (rf & 2) {
$r3$.ɵɵproperty("ngIf", ctx.someFlag);
$r3$.ɵɵadvance(1);
$r3$.ɵɵproperty("ngIf", ctx.someFlag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"verifyUniqueConsts"
]
}
],
"skipForTemplatePipeline": true
]
},
{
"description": "should be generated for ICU-only i18n blocks",
Expand Down Expand Up @@ -43,8 +42,7 @@
"verifyUniqueConsts"
]
}
],
"skipForTemplatePipeline": true
]
},
{
"description": "should not be generated in case we have styling instructions",
Expand All @@ -53,13 +51,19 @@
],
"expectations": [
{
"files": [
{
"generated": "styles.js",
"expected": "styles.template.js",
"templatePipelineExpected": "styles.pipeline.js"
}
],
"extraChecks": [
"verifyPlaceholdersIntegrity",
"verifyUniqueConsts"
]
}
],
"skipForTemplatePipeline": true
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
decls: 4,
vars: 0,
consts: () => {
__i18nMsg__('Text #1', [], {}, {})
__i18nMsg__('Text #2', [], {}, {})
return [
$i18n_0$,
$i18n_1$,
[__AttributeMarker.Classes__, "myClass"],
[__AttributeMarker.Styles__, "padding", "10px"]
];
},
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "span", 2);
$r3$.ɵɵi18n(1, 0);
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(2, "span", 3);
$r3$.ɵɵi18n(3, 1);
$r3$.ɵɵelementEnd();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1025,3 +1025,34 @@ export declare class MyModule {
static ɵinj: i0.ɵɵInjectorDeclaration<MyModule>;
}

/****************************************************************************************************
* PARTIAL FILE: template_with_structural_directive.js
****************************************************************************************************/
import { Component } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
}
MyComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
MyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "0.0.0-PLACEHOLDER", type: MyComponent, isStandalone: true, selector: "my-component", ngImport: i0, template: `
<ng-template *ngIf="true">Content</ng-template>
`, isInline: true });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyComponent, decorators: [{
type: Component,
args: [{
selector: 'my-component',
standalone: true,
template: `
<ng-template *ngIf="true">Content</ng-template>
`,
}]
}] });

/****************************************************************************************************
* PARTIAL FILE: template_with_structural_directive.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
static ɵfac: i0.ɵɵFactoryDeclaration<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MyComponent, "my-component", never, {}, {}, never, never, true, never>;
}

Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,17 @@
"failureMessage": "Incorrect template"
}
]
},
{
"description": "should handle structural directive on ng-template",
"inputFiles": [
"template_with_structural_directive.ts"
],
"expectations": [
{
"failureMessage": "Incorrect template"
}
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function MyComponent_0_ng_template_0_Template(rf, ctx) {
if (rf & 1) {
i0.ɵɵtext(0, "Content");
}
}
function MyComponent_0_Template(rf, ctx) {
if (rf & 1) {
i0.ɵɵtemplate(0, MyComponent_0_ng_template_0_Template, 1, 0, "ng-template");
}
}
decls: 1,
vars: 1,
consts: [[4, "ngIf"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
i0.ɵɵtemplate(0, MyComponent_0_Template, 1, 0, null, 0);
}
if (rf & 2) {
i0.ɵɵproperty("ngIf", true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {Component} from '@angular/core';

@Component({
selector: 'my-component',
standalone: true,
template: `
<ng-template *ngIf="true">Content</ng-template>
`,
})
export class MyComponent {
}
6 changes: 3 additions & 3 deletions packages/compiler/src/ml_parser/html_tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ let TAG_DEFINITIONS!: {[key: string]: HtmlTagDefinition};
export function getHtmlTagDefinition(tagName: string): HtmlTagDefinition {
if (!TAG_DEFINITIONS) {
DEFAULT_TAG_DEFINITION = new HtmlTagDefinition({canSelfClose: true});
TAG_DEFINITIONS = {
TAG_DEFINITIONS = Object.assign(Object.create(null), {
'base': new HtmlTagDefinition({isVoid: true}),
'meta': new HtmlTagDefinition({isVoid: true}),
'area': new HtmlTagDefinition({isVoid: true}),
Expand Down Expand Up @@ -142,10 +142,10 @@ export function getHtmlTagDefinition(tagName: string): HtmlTagDefinition {
}),
'textarea': new HtmlTagDefinition(
{contentType: TagContentType.ESCAPABLE_RAW_TEXT, ignoreFirstLf: true}),
};
});

new DomElementSchemaRegistry().allKnownElementNames().forEach(knownTagName => {
if (!TAG_DEFINITIONS.hasOwnProperty(knownTagName) && getNsPrefix(knownTagName) === null) {
if (!TAG_DEFINITIONS[knownTagName] && getNsPrefix(knownTagName) === null) {
TAG_DEFINITIONS[knownTagName] = new HtmlTagDefinition({canSelfClose: false});
}
});
Expand Down
Loading

0 comments on commit af352fd

Please sign in to comment.