Branch: master
-
fix(core): error when invoking callbacks registered via ViewRef.onDes…
…troy (#37543) Invoking a callback registered through `ViewRef.onDestroy` throws an error, because we weren't registering it correctly in the internal data structure. These changes also remove the `storeCleanupFn` function, because it was mostly identical to `storeCleanupWithContext` and was only used in one place. Fixes #36213. PR Close #37543
-
fix(core): don't consider inherited NG_ELEMENT_ID during DI (#37574)
Special DI tokens like `ChangeDetectorRef` and `ElementRef` can provide a factory via `NG_ELEMENT_ID`. The problem is that we were reading it off the token as `token[NG_ELEMENT_ID]` which will go up the prototype chain if it couldn't be found on the current token, resulting in the private `ViewRef` API being exposed, because it extends `ChangeDetectorRef`. These changes fix the issue by guarding the property access with `hasOwnProperty`. Fixes #36235. PR Close #37574
-
fix(core): do not trigger CSP alert/report in Firefox and Chrome (#36578
) (#36578) If [innerHTML] is used in a component and a Content-Security-Policy is set that does not allow inline styles then Firefox and Chrome show the following message: > Content Security Policy: The page’s settings observed the loading of a resource at self (“default-src”). A CSP report is being sent. This message is caused because Angular is creating an inline style tag to test for a browser bug that we use to decide what sanitization strategy to use, which causes CSP violation errors if inline CSS is prohibited. This test is no longer necessary, since the `DOMParser` is now safe to use and the `style` based check is redundant. In this fix, we default to using `DOMParser` if it is available and fall back to `createHTMLDocument()` if needed. This is the approach used by DOMPurify too. The related unit tests in `html_sanitizer_spec.ts`, "should not allow JavaScript execution when creating inert document" and "should not allow JavaScript hidden in badly formed HTML to get through sanitization (Firefox bug)", are left untouched to assert that the behavior hasn't changed in those scenarios. Fixes #25214. PR Close #36578
-
fix(language-service): incorrect autocomplete results on unknown symb…
…ol (#37518) This commit fixes a bug whereby the language service would incorrectly return HTML elements if autocomplete is requested for an unknown symbol. This is because we walk through every possible scenario, and fallback to element autocomplete if none of the scenarios match. The fix here is to return results from interpolation if we know for sure we are in a bound text. This means we will now return an empty results if there is no suggestions. This commit also refactors the code a little to make it easier to understand. PR Close #37518
-
-
ci: exclude "docs" commit type from minBodyLength commit message vali…
…dation (#37764) docs commits are sometimes trivial (e.g. an obvious typo fix) and in such cases its very akward to to write up 100 chars worth of text about why this typo fix is the best thing in the world and why it is so important and crucial that we must know why we are fixing the typo at all. After all most typos are not just typos. Or are they? We'll shall see... PR Close #37764
-
feat(platform-browser): Allow `sms`-URLs (#31463)
sms ulr is already supported by google/closure-library and and validations are added to check if the body passed is safe or not you can refer https://github.com/google/closure-library/blob/bb7ea653194b590711614fd79b0a88a38a600740/closure/goog/html/safeurl.js#L440-L454 for more details Fixes #31462 PR Close #31463
-
build: move shims_for_IE to third_party directory (#37624)
The shims_for_IE.js file contains vendor code that predates the third_party directory. This file is currently used for internal karma testing setup. This change corrects this by moving the shims_for_IE file to //third_part/ PR Close #37624
-
refactor(compiler-cli): Remove any cast for CompilerHost (#37079)
This commit removes the FIXME for casting CompilerHost to any since google3 is now already on TS 3.8. PR Close #37079
-
fix(language-service): reinstate getExternalFiles() (#37750)
`getExternalFiles()` is an API that could optionally be provided by a tsserver plugin to notify the server of any additional files that should belong to a particular project. This API was removed in #34260 mainly due to performance reasons. However, with the introduction of "solution-style" tsconfig in typescript 3.9, the Angular extension could no longer reliably detect the owning Project solely based on the ancestor tsconfig.json. In order to support this use case, we have to reinstate `getExternalFiles()`. Fixes angular/vscode-ng-language-service#824 PR Close #37750
-
fix(dev-infra): merge script should not always require full repo perm…
…issions (#37718) We recently added OAuth scope checking to the dev-infra Git client and started leveraging it for the merge script. We set the `repo` scope as required for running the merge script. We can loosen this requirement as in the Angular org where the script is consumed, only pull requests on public repositories are merged through the script. This should help with reducing the risk with compromised tokens as no access had to be granted on `repo:invite`, `repo_deployment` etc. PR Close #37718
-
fix(dev-infra): support running scripts from within a detached head (#…
…37737) Scripts provided in the `ng-dev` command might use local `git` commands. For such scripts, we keep track of the branch that has been checked out before the command has been invoked. We do this so that we can later (upon command completion) restore back to the original branch. We do not want to leave the Git repository in a dirty state. It looks like this logic currently only deals with branches but does not work properly when a command is invoked from a detached head. We can make it work by just checking out the previous revision (if no branch is checked out). PR Close #37737
-
ci(docs-infra): store JS bundles as CI artifacts to debug size check …
…flakes (#37703) As reported in #37699, the size of the main angular.io bundle sometimes ends up bigger than expected on CI. This usually goes away after rerunning the job a couple of times. It is unclear what is causing this. In order to help debug the issue, this commit stores the JS files that are checked as part of the aio payload-size check as CI artifacts, where they can be retrieved from and inspected. PR Close #37703
-
-
fix(docs-infra): fix deploy-to-firebase.sh for master and v10.0.x bra…
…nches (#37762) The deployment to aio is currently failing because #37721 introduced "project" entry into the firebase.json which means that we now need to select the deployment target before deploying to firebase. This change fixes the issue and refactors the file to be easier to read. I also added extra echo statements so that the CI logs are easier to read in case we need to troubleshoot future issues. PR Close #37762
-
test(compiler-cli): fix assertion of diagnostic filename on Windows (#…
…37758) Several partial_evaluator tests in the diagnostics_spec check assert correctness of diagnostic filenames. Previously these assertions compared a resolved (`absoluteFrom`) filename with the TypeScript `ts.SourceFile`'s `fileName` string, which caused the tests to fail on Windows because the drive letter case differed. This commit changes the assertions to use `absoluteFromSourceFile` instead of the `fileName` string, resulting in an apples-to-apples comparison of canonicalized paths. PR Close #37758
-
fix(docs-infra): fix typo in the deploy-to-firebase.sh script (#37754)
This typo caused the script to fail on Linux (interestingly it works fine on Mac). This is a painful reminder that we should not write any more Bash scripts EVER. shelljs FTW! :-) PR Close #37754
-
fix(core): cleanup DOM elements when root view is removed (#37600)
Currently when bootstrapped component is being removed using `ComponentRef.destroy` or `NgModuleRef.destroy` methods, DOM nodes may be retained in the DOM tree. This commit fixes that problem by always attaching host element of the internal root view to the component's host view node, so the cleanup can happen correctly. Resolves #36449. PR Close #37600
-
feat(platform-server): add option for absolute URL HTTP support (#37539)
In version 10.0.0-next.8, we introduced absolute URL support for server-based HTTP requests, so long as the fully-resolved URL was provided in the initial config. However, doing so represents a breaking change for users who already have their own interceptors to model this functionality, since our logic executes before all interceptors fire on a request. See original PR #37071. Therefore, we introduce a flag to make this change consistent with v9 behavior, allowing users to opt in to this new behavior. This commit also fixes two issues with the previous implementation: 1. if the server was initiated with a relative URL, the absolute URL construction would fail because needed components were empty 2. if the user's absolute URL was on a port, the port would not be included PR Close #37539
-
fix(migrations): do not incorrectly add todo for @Injectable or @pipe (…
…#37732) As of v10, the `undecorated-classes-with-decorated-fields` migration generally deals with undecorated classes using Angular features. We intended to run this migation as part of v10 again as undecorated classes with Angular features are no longer supported in planned v11. The migration currently behaves incorrectly in some cases where an `@Injectable` or `@Pipe` decorated classes uses the `ngOnDestroy` lifecycle hook. We incorrectly add a TODO for those classes. This commit fixes that. Additionally, this change makes the migration more robust to not migrate a class if it inherits from a component, pipe injectable or non-abstract directive. We previously did not need this as the undecorated-classes-with-di migration ran before, but this is no longer the case. Last, this commit fixes an issue where multiple TODO's could be added. This happens when multiple Angular CLI build targets have an overlap in source files. Multiple programs then capture the same source file, causing the migration to detect an undecorated class multiple times (i.e. adding a TODO twice). Fixes #37726. PR Close #37732
-
refactor(compiler-cli): more accurate reporting of complex function c…
…all (#37587) This commit introduces a dedicated `DynamicValue` kind to indicate that a value cannot be evaluated statically as the function body is not just a single return statement. This allows more accurate reporting of why a function call failed to be evaluated, i.e. we now include a reference to the function declaration and have a tailor-made diagnostic message. PR Close #37587
-
feat(compiler-cli): explain why an expression cannot be used in AOT c…
…ompilations (#37587) During AOT compilation, the value of some expressions need to be known at compile time. The compiler has the ability to statically evaluate expressions the best it can, but there can be occurrences when an expression cannot be evaluated statically. For instance, the evaluation could depend on a dynamic value or syntax is used that the compiler does not understand. Alternatively, it is possible that an expression could be statically evaluated but the resulting value would be of an incorrect type. In these situations, it would be helpful if the compiler could explain why it is unable to evaluate an expression. To this extend, the static interpreter in Ivy keeps track of a trail of `DynamicValue`s which follow the path of nodes that were considered all the way to the node that causes an expression to be considered dynamic. Up until this commit, this rich trail of information was not surfaced to a developer so the compiler was of little help to explain why static evaluation failed, resulting in situations that are hard to debug and resolve. This commit adds much more insight to the diagnostic that is produced for static evaluation errors. For dynamic values, the trail of `DynamicValue` instances is presented to the user in a meaningful way. If a value is available but not of the correct type, the type of the resolved value is shown. Resolves FW-2155 PR Close #37587
-
refactor(compiler-cli): create diagnostics using `ts.DiagnosticRelate…
…dInformation` (#37587) Previously, an anonymous type was used for creating a diagnostic with related information. The anonymous type would then be translated into the necessary `ts.DiagnosticRelatedInformation` shape within `makeDiagnostic`. This commit switches the `makeDiagnostic` signature over to taking `ts.DiagnosticRelatedInformation` directly and introduces `makeRelatedInformation` to easily create such objects. This is done to aid in making upcoming work more readable. PR Close #37587
-
perf(compiler-cli): fix regressions in incremental program reuse (#37641
) Commit 4213e8d introduced shim reference tagging into the compiler, and changed how the `TypeCheckProgramHost` worked under the hood during the creation of a template type-checking program. This work enabled a more incremental flow for template type-checking, but unintentionally introduced several regressions in performance, caused by poor incrementality during `ts.Program` creation. 1. The `TypeCheckProgramHost` was made to rely on the `ts.CompilerHost` to retrieve instances of `ts.SourceFile`s from the original program. If the host does not return the original instance of such files, but instead creates new instances, this has two negative effects: it incurs additional parsing time, and it interferes with TypeScript's ability to reuse information about such files. 2. During the incremental creation of a `ts.Program`, TypeScript compares the `referencedFiles` of `ts.SourceFile` instances from the old program with those in the new program. If these arrays differ, TypeScript cannot fully reuse the old program. The implementation of reference tagging introduced in 4213e8d restores the original `referencedFiles` array after a `ts.Program` is created, which means that future incremental operations involving that program will always fail this comparison, effectively limiting the incrementality TypeScript can achieve. Problem 1 exacerbates problem 2: if a new `ts.SourceFile` is created by the host after shim generation has been disabled, it will have an untagged `referencedFiles` array even if the original file's `referencedFiles` was not restored, triggering problem 2 when creating the template type-checking program. To fix these issues, `referencedFiles` arrays are now restored on the old `ts.Program` prior to the creation of a new incremental program. This allows TypeScript to get the most out of reusing the old program's data. Additionally, the `TypeCheckProgramHost` now uses the original `ts.Program` to retrieve original instances of `ts.SourceFile`s where possible, preventing issues when a host would otherwise return fresh instances. Together, these fixes ensure that program reuse is as incremental as possible, and tests have been added to verify this for certain scenarios. An optimization was further added to prevent the creation of a type-checking `ts.Program` in the first place if no type-checking is necessary. PR Close #37641

