Skip to content

Commit

Permalink
fix(collapse): no animations in production mode (#4044)
Browse files Browse the repository at this point in the history
This is caused by the Terser `pure_getters` optimization.
If used only once (ex. when importing ONLY `NgbCollapseModule`), the `reflow` function is broken:

```ts
// source
export function reflow(element: HTMLElement) {
  return (element || document.body).offsetHeight;
}

reflow(el);

// inlined in production
function(element) {
    element || document
}(element)
```

Fixes #3972
  • Loading branch information
maxokorokov committed Mar 22, 2021
1 parent 71ca123 commit 5e25272
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function closest(element: HTMLElement, selector?: string): HTMLElement |
* @param element element where to apply the reflow
*/
export function reflow(element: HTMLElement) {
return (element || document.body).offsetHeight;
return (element || document.body).getBoundingClientRect();
}

/**
Expand Down

0 comments on commit 5e25272

Please sign in to comment.