angular/packages
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
..
animations test: remove duplicate tests (#67518) 2026-03-11 13:37:33 -07:00
benchpress build: update cross-repo angular dependencies 2026-03-05 11:43:25 -08:00
common fix(http): add CSP nonce support to JsonpClientBackend 2026-04-13 16:01:11 +03:00
compiler fix(compiler): don't escape dollar sign in literal expression 2026-04-10 09:23:50 +03:00
compiler-cli refactor(compiler-cli): decouple SymbolReference from AST nodes in template checker 2026-04-14 12:32:48 +03:00
core feat(core): implement Angular DI graph in-page AI tool 2026-04-14 18:35:51 +03:00
docs/di build: format md files 2025-11-06 10:03:05 -08:00
elements refactor(core): remove ComponentFactoryResolver usages 2026-04-13 16:00:03 +03:00
examples feat(core): bootstrap via ApplicationRef with config 2026-04-07 12:48:53 -07:00
forms feat(forms): shim legacy NG_VALIDATORS into parseErrors for CVA mode (#67943) 2026-04-14 18:32:24 +03:00
language-service refactor: remove all deep imports in language service 2026-04-13 11:16:26 +03:00
localize fix(localize): validate locale in getOutputPathFn to prevent path traversal 2026-03-30 12:15:26 +02:00
misc/angular-in-memory-web-api fix(http): Don't on Passthru outside of reactive context 2026-04-15 10:20:48 -04:00
platform-browser refactor(core): deprecate withIncrementalHydration 2026-04-13 18:53:21 +03:00
platform-browser-dynamic build: update minimum supported Node.js versions 2026-02-25 07:57:18 -08:00
platform-server fix(platform-server): prevent SSRF bypasses via protocol-relative and backslash URLs 2026-04-15 10:23:52 -04:00
private/testing build: consolidate domino bundling in platform-server 2026-03-25 13:31:05 -07:00
router fix(router): normalize multiple leading slashes in URL parser 2026-04-14 12:34:03 +03:00
service-worker fix(service-worker): resolve TS 6.0 compatibility for messageerror listener 2026-04-09 21:46:28 +03:00
ssr/docs build: add node type for api extraction 2026-02-11 13:57:58 -08:00
upgrade refactor(core): remove ComponentFactoryResolver usages 2026-04-13 16:00:03 +03:00
zone.js fix(zone.js): allow draining microtasks in Promise.then (through flag) 2026-04-15 10:31:28 -04:00
BUILD.bazel refactor(platform-browser): remove Hammer integration 2026-03-19 16:13:20 -07:00
circular-deps-test.conf.cjs build: use Node.js built-in TypeScript support for dev-infra scripts 2026-01-02 08:15:40 +01:00
empty.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
goog.d.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
license-banner.txt docs: update copyright year 2026-01-07 12:28:34 -05:00
package.json build: prepare for compiler-cli to be using ts_project (#61181) 2025-05-09 15:59:46 +00:00
README.md build: format md files 2025-11-06 10:03:05 -08:00
system.d.ts refactor: update packages/core:{core,src} to ts_project (#61275) 2025-05-14 12:01:51 +00:00
tsconfig-build.json Revert "refactor(compiler-cli): remove deep imports from compiler-cli (#64732)" 2025-11-06 13:09:01 -08:00
tsconfig-legacy-saucelabs.json feat(core): support TypeScript 5.5 (#56096) 2024-05-29 15:33:33 +02:00
tsconfig-test.json
tsconfig.json feat(compiler-cli): enable type checking of host bindings by default (#63654) 2025-09-09 14:34:29 -07:00
tsec-exemption.json
types.d.ts refactor(platform-browser): remove Hammer integration 2026-03-19 16:13:20 -07:00

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT