Deliver web apps with confidence 🚀
Find a file
arturovt fc6a7eea68 fix(zone.js): allow draining microtasks in Promise.then (through flag)
These changes are essentially the same as those introduced in
angular#45273, but they include backward compatibility
for applications that explicitly rely on the order in which microtasks are drained.

This is critically important for our code and other third-party code, which is
beyond our control, to work properly. If a microtask is scheduled within an event
listener to be executed "later", it should indeed be executed later and not synchronously,
as this would break the expected flow of code execution.

The simple code that reproduces the behavior that exists now:

```ts
Zone.current.fork({name: 'child'}).run(() => {
  const div = document.createElement('div');
  div.style.height = '200px';
  div.style.width = '200px';
  div.style.backgroundColor = 'red';
  document.body.appendChild(div);

  function listener() {
    Promise.resolve().then(() => {
      div.style.height = '400px';
    });
  }

  div.addEventListener('fakeEvent', listener);
  div.dispatchEvent(new Event('fakeEvent'));
  console.log(div.getBoundingClientRect().height); // 400
});
```

The code above logs 400 as the height, but it should actually log 200 because the
height is updated in a microtask within the event listener.

When using Angular with microfrontend applications, especially when other apps might be
using React, zone.js can disrupt the classical order of operations. For example, when using a
`react-component/trigger`, it schedules a microtask within an event listener using
`Promise.resolve().then(...)` to determine whether the event needs to be re-dispatched.
The event is re-dispatched when the layout has changed, which is why a microtask is used.

With this change, we introduce a global configuration flag,
`__zone_symbol__enable_native_microtask_draining`, to allow consumers to enable
microtask draining within a browser microtask.

This flag is necessary to prevent any breaking changes resulting from this modification.
The previous attempt to address this issue caused a significant number of failures in g3.
Therefore, we are hiding that fix behind the configuration flag.

Closes angular#44446
Closes angular#55590
Closes angular#51328
2026-04-15 10:31:28 -04:00
.agent refactor: add flaky tests workflow 2026-04-10 16:45:32 +03:00
.devcontainer build: update dev container configuration 2026-01-12 13:39:29 -08:00
.gemini refactor: ignore pnpm-lock.yaml in Gemini code reviews 2026-03-19 14:55:55 -07:00
.github build: update cross-repo angular dependencies 2026-04-08 11:04:49 -07:00
.husky build: use pnpm as the package manager instead of yarn (#62924) 2025-07-31 22:06:27 +00:00
.ng-dev refactor(compiler-cli): Export hybrid_analysis symbols 2026-03-10 10:18:36 -07:00
.vscode build: use @angular/language-service from source (#64306) 2025-10-09 10:00:31 -07:00
adev docs(docs-infra): add background to playground template dropdown 2026-04-15 10:26:05 -04:00
contributing-docs docs: draft PR spam policy addendum 2026-04-13 20:54:23 +03:00
dev-app build: update cross-repo angular dependencies 2026-04-09 14:13:51 +03:00
devtools release: bump Angular DevTools version to 1.14.1 2026-04-08 12:15:55 -07:00
goldens feat(forms): shim legacy NG_VALIDATORS into parseErrors for CVA mode (#67943) 2026-04-14 18:32:24 +03:00
integration test: use strict mode for ng_elements integration test 2026-04-13 14:12:48 +03:00
modules build: update all non-major dependencies 2026-04-09 15:41:19 +03:00
packages fix(zone.js): allow draining microtasks in Promise.then (through flag) 2026-04-15 10:31:28 -04:00
scripts ci: support publishing dev-skills to snapshot repository 2026-03-23 09:49:11 -07:00
skills/dev-skills docs: add "Using Agent Skills" + command to skills README.md 2026-04-13 21:12:25 +03:00
third_party build: drop usage of pkg_web (#62990) 2025-08-05 10:08:47 +02:00
tools build: consolidate domino bundling in platform-server 2026-03-25 13:31:05 -07:00
vscode-ng-language-service refactor(vscode-extension): allow toggle attributes via LS. 2026-04-13 22:10:16 +03:00
.bazelrc build: update to bazel version 8.4.2 2025-12-08 10:21:59 -08:00
.bazelversion build: update dependency bazel to v8.6.0 2026-02-27 09:09:51 -08:00
.clang-format feat(tooling): Add a .clang-format for automated JavaScript formatting. 2015-04-02 08:44:34 -07:00
.editorconfig build: use https link to editorconfig.org in .editorconfig (#27664) 2018-12-18 09:30:09 -08:00
.git-blame-ignore-revs build: exclude formating commit 2026-03-19 15:54:27 -07:00
.gitattributes build: cleanup .gitattributes file and remove outdated CRLF attribute (#46513) 2022-06-28 13:38:27 -07:00
.gitignore build: update dev container configuration 2026-01-12 13:39:29 -08:00
.gitmessage docs: move commit message guidelies to a separate file (#58786) 2025-03-04 19:35:54 +00:00
.mailmap build: add a Git .mailmap with my new name (#19550) 2017-10-09 14:35:30 -07:00
.npmrc build: ensure optimization rule can use compiler-cli from HEAD (#61810) 2025-06-02 09:52:57 -04:00
.nvmrc build: update dependency node to v22.22.2 2026-03-25 12:57:20 -07:00
.pnpmfile.cjs build: improve dependency management for local packages 2025-11-12 09:34:27 -08:00
.prettierignore build: update cross-repo angular dependencies 2026-02-25 10:17:51 -08:00
.prettierrc ci: enable embeddedLanguageFormatting for prettier 2025-12-15 09:54:48 -08:00
.pullapprove.yml ci: exclude test files from primitives review 2026-04-01 20:27:26 +02:00
AGENTS.md docs: add testing tips to AGENTS.md 2026-02-17 08:23:59 -08:00
browser-providers.conf.d.ts build: share Saucelabs browsers between karma test targets using background Saucelabs daemon and custom karma launcher (#49200) 2023-05-15 09:21:46 -07:00
browser-providers.conf.js refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
BUILD.bazel build: use snapshot builds for dependencies in @angular/language-server (#64334) 2025-10-10 06:48:51 -07:00
CHANGELOG.md release: cut the v22.0.0-next.7 release 2026-04-08 12:48:22 -07:00
CHANGELOG_ARCHIVE.md build: format md files 2025-11-06 10:03:05 -08:00
CODE_OF_CONDUCT.md build: format md files 2025-11-06 10:03:05 -08:00
context7.json docs: add context7.json config (#63000) 2025-08-05 18:15:38 +02:00
CONTRIBUTING.md docs: fix typos and grammar errors across documentation 2026-04-08 09:40:47 -07:00
gulpfile.js refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
karma-js.conf.js build: update to bazel 7.6.0 (#63096) 2025-08-14 13:01:30 +02:00
LICENSE docs: update copyright year 2026-01-07 12:28:34 -05:00
MODULE.bazel build: update cross-repo angular dependencies 2026-04-13 15:22:58 +03:00
MODULE.bazel.lock build: update cross-repo angular dependencies 2026-04-13 15:22:58 +03:00
package.json build: update dependency diff to v9 2026-04-15 10:20:07 -04:00
packages.bzl docs(docs-infra): remove unused examples 2026-01-26 23:19:35 +00:00
pnpm-lock.yaml build: update dependency diff to v9 2026-04-15 10:20:07 -04:00
pnpm-workspace.yaml ci: add zone.js to minimumReleaseAgeExclude 2026-02-19 12:41:19 -08:00
README.md docs: fix lazy loading documentation reference 2025-12-08 08:47:40 -08:00
renovate.json build: remove redundant Bazel lockfile update workarounds 2026-03-17 13:53:07 -06:00
REPO.bazel build: migrate Bazel ignore rules from .bazelignore to REPO.bazel 2025-12-17 10:14:00 -08:00
SECURITY.md docs: update security guide link to adev (#56469) 2024-06-17 08:54:08 -07:00
tsconfig-tslint.json build: update tslint configuration (#61146) 2025-05-06 13:35:24 -07:00
tslint.json build: add a noDuplicateEnumValue rule (#63483) 2025-09-10 22:16:10 +00:00

Angular - The modern web developer's platform

angular-logo
Angular is a development platform for building mobile and desktop web applications
using TypeScript/JavaScript and other languages.

angular.dev

Contributing Guidelines · Submit an Issue · Blog

Angular on npm


Documentation

Get started with Angular, learn the fundamentals and explore advanced topics on our documentation website.

Advanced

Local Development

To contribute to the Angular Docs, check out the Angular.dev README

Development Setup

Prerequisites

Setting Up a Project

Install the Angular CLI globally:

npm install -g @angular/cli

Create workspace:

ng new [PROJECT NAME]

Run the application:

cd [PROJECT NAME]
ng serve

Angular is cross-platform, fast, scalable, has incredible tooling, and is loved by millions.

Quickstart

Get started in 5 minutes.

Ecosystem

angular ecosystem logos

Changelog

Learn about the latest improvements.

Upgrading

Check out our upgrade guide to find out the best way to upgrade your project.

Contributing

Contributing Guidelines

Read through our contributing guidelines to learn about our submission process, coding rules, and more.

Want to Help?

Want to report a bug, contribute some code, or improve the documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues labeled as help wanted or good first issue.

Code of Conduct

Help us keep Angular open and inclusive. Please read and follow our Code of Conduct.

Community

Join the conversation and help the community.

Love Angular badge

Love Angular? Give our repo a star ⬆️.