Skip to content

Commit

Permalink
fix(bug): stops auto-applying zone patches for ShadyDOM when requesti…
Browse files Browse the repository at this point in the history
…ng both Zone and shadow-dom since this may lead to issues in IE11
  • Loading branch information
wessberg committed Apr 2, 2019
1 parent 9ec3528 commit fb6c5cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,14 @@ For example: `systemjs|variant=s` selects the _s_ variant, while `systemjs|varia

[Zone.js](https://github.com/angular/zone.js/), which is supported by Polyfiller, can be configured with some extra options to enhance its operation or support interoperability with more APIs:

| Option | Description |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `error` | Generates more readable Stack traces when using Zone |
| `shadydom` | _This will be automatically applied if the Shadow DOM polyfill is being loaded along with Zone_. |
| `mediaquery` | Patches the [Media Query API](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) |
| `rxjs` | Patches [Rxjs](https://github.com/ReactiveX/rxjs) |
| `fetch` | Patches the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). _This will be automatically applied if the Fetch polyfill is being loaded along with Zone_. |
| `resizeobserver` | Patches the [ResizeObserver API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver). _This will be automatically applied if the ResizeObserver polyfill is being loaded along with Zone_. |
| Option | Description |
| ---------------- | -------------------------------------------------------------------------------------------------- |
| `error` | Generates more readable Stack traces when using Zone |
| `shadydom` | Makes Zone compatible with the ShadyDOM polyfill. |
| `mediaquery` | Patches the [Media Query API](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) |
| `rxjs` | Patches [Rxjs](https://github.com/ReactiveX/rxjs) |
| `fetch` | Patches the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). |
| `resizeobserver` | Patches the [ResizeObserver API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver). |

#### Extra options for `shadow-dom`

Expand Down
15 changes: 3 additions & 12 deletions src/service/polyfill-builder/polyfill-builder-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,9 @@ export class PolyfillBuilderService implements IPolyfillBuilderService {
}
}

// Check if any web component polyfill has been requested
const hasWCPolyfill = [...polyfillSet].some(({name}) => name === "custom-elements" || name === "shadow-dom");

// If any web component polyfill has been requested, or if the 'shadydom' zone extension has been explicitly requested
// add it to the Zone.js polyfill buffer
if (hasWCPolyfill || (polyfillFeature.meta != null && polyfillFeature.meta.shadydom === true)) {
if (polyfillFeature.meta != null && polyfillFeature.meta.shadydom === true) {
for (const shadydomPath of ensureArray(meta.shadydom)) {
const shadyDomExtensionPathInput = join(rootDirectory, shadydomPath);
const resolvedShadyDomExtensionPath = sync(shadyDomExtensionPathInput, SYNC_OPTIONS);
Expand Down Expand Up @@ -201,11 +198,8 @@ export class PolyfillBuilderService implements IPolyfillBuilderService {
}
}

// Check if any fetch polyfill has been requested
const hasFetchPolyfill = [...polyfillSet].some(({name}) => name === "fetch");

// If the Zone-patching of 'fetch' is requested, or if 'fetch' is requested as a polyfill along with Zone add it to the polyfill buffer for Zone.js
if (hasFetchPolyfill || (polyfillFeature.meta != null && polyfillFeature.meta.fetch === true)) {
if (polyfillFeature.meta != null && polyfillFeature.meta.fetch === true) {
for (const fetchPath of ensureArray(meta.fetch)) {
const fetchExtensionPathInput = join(rootDirectory, fetchPath);
const resolvedFetchExtensionPath = sync(fetchExtensionPathInput, SYNC_OPTIONS);
Expand All @@ -217,11 +211,8 @@ export class PolyfillBuilderService implements IPolyfillBuilderService {
}
}

// Check if any fetch polyfill has been requested
const hasResizeObserverPolyfill = [...polyfillSet].some(({name}) => name === "resize-observer");

// If the Zone-patching of 'ResizeObserver' is requested or if ResizeObserver is requested as a polyfill along with Zone.js, add it to the polyfill buffer for Zone.js
if (hasResizeObserverPolyfill || (polyfillFeature.meta != null && polyfillFeature.meta.resizeobserver === true)) {
if (polyfillFeature.meta != null && polyfillFeature.meta.resizeobserver === true) {
for (const resizeobserverPath of ensureArray(meta.resizeobserver)) {
const resizeObserverExtensionPathInput = join(rootDirectory, resizeobserverPath);
const resolvedResizeObserverExtensionPath = sync(resizeObserverExtensionPathInput, SYNC_OPTIONS);
Expand Down

0 comments on commit fb6c5cf

Please sign in to comment.