Skip to content

Commit e3e4011

Browse files
committed
remove afterNextRender in devtools-utils
Since angular-devtools already run the code within afterNextRender in browser env, we don't like to wrap the panel returned from utils
1 parent d81e976 commit e3e4011

File tree

1 file changed

+13
-17
lines changed
  • packages/devtools-utils/src/angular

1 file changed

+13
-17
lines changed

packages/devtools-utils/src/angular/panel.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { afterNextRender } from '@angular/core'
2-
31
export type DevtoolsPanelProps = {
42
theme?: 'dark' | 'light' | 'system'
53
}
@@ -34,7 +32,7 @@ export function createAngularPanel<
3432
return [
3533
() =>
3634
(inputs: () => TComponentProps, host: HTMLElement): (() => void) => {
37-
const panel = document.createElement('div')
35+
const panel = host.ownerDocument.createElement('div')
3836
panel.style.height = '100%'
3937
let unmount: null | (() => void) = null
4038

@@ -43,22 +41,20 @@ export function createAngularPanel<
4341
unmount = () => instance.unmount()
4442
}
4543

46-
afterNextRender(() => {
47-
host.appendChild(panel)
44+
host.appendChild(panel)
4845

49-
const isConstructor = isPanelClassConstructor<
50-
TComponentProps,
51-
TCoreDevtoolsClass
52-
>(CoreClass)
46+
const isConstructor = isPanelClassConstructor<
47+
TComponentProps,
48+
TCoreDevtoolsClass
49+
>(CoreClass)
5350

54-
if (isConstructor) {
55-
mount(new CoreClass(inputs()))
56-
} else {
57-
CoreClass()
58-
.then((ResolvedCoreClass) => new ResolvedCoreClass(inputs()))
59-
.then(mount)
60-
}
61-
})
51+
if (isConstructor) {
52+
mount(new CoreClass(inputs()))
53+
} else {
54+
CoreClass()
55+
.then((ResolvedCoreClass) => new ResolvedCoreClass(inputs()))
56+
.then(mount)
57+
}
6258

6359
return () => {
6460
unmount?.()

0 commit comments

Comments
 (0)