primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Error: Expecting instance of DOM when building project without --prod

Open CazimirRoman opened this issue 5 years ago • 5 comments

I'm submitting a ... (check one with "x")

[ X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports) Please demonstrate your case at stackblitz by using the issue template below. Issues without a test case have much less possibility to be reviewd in detail and assisted.

https://stackblitz.com/github/primefaces/primeng-issue-template

Current behavior When integrating a prime NG component such as context menu or tooltip into a wrapper component, building and serving without using the --prod tag will result in an error which relates to listeners not being correctly attached.

This means that clicking outside does not trigger the context menu to close. The browser context menu is also shown above the Prime NG context menu and e.preventDefault() must be explicitly implemented.

Expected behavior The error should not show and listeners should bind correctly.

Minimal reproduction of the problem with instructions

  • Create a new angular component.
  • Import the prime ng package
  • Open the html template and add a context menu using the appropiate tags: as explained here: https://primefaces.org/primeng/showcase/#/contextmenu
  • Build and serve the app
  • Right click on the element which has the context menu
  • Open the Dev console and check that the error appears:

ERROR Error: Expecting instance of DOM Element at assertDomElement (core.js:26068) at getListeners (core.js:25947) at DebugNode__POST_R3__.get listeners [as listeners] (core.js:43593) at DebugRenderer2.listen (core.js:47700) at ContextMenu.bindGlobalListeners (primeng-contextmenu.js:214) at ContextMenu.show (primeng-contextmenu.js:161) at ContextMenuPrimeNgComponent.show (context-menu-prime-ng.component.ts:24) at ContextMenuPrimeNgDirective.onContextMenu (context-menu-prime-ng.directive.ts:30) at Object.handleEvent (context-menu-prime-ng-examples.component.html:3) at handleEvent (core.js:45729) View_ContextMenuPrimeNgExamplesComponent_0 @ context-menu-prime-ng-examples.component.html:3 context-menu-prime-ng-examples.component.html:3

What is the motivation / use case for changing the behavior?

Please tell us about your environment: Windows 10, Webstorm, NPM

  • Angular version: 9.0.2

  • PrimeNG version: 10.0.3

  • Browser: [Chrome ]

  • Language: [Typescript]

CazimirRoman avatar Apr 16 '21 15:04 CazimirRoman

Unable to replicate with PrimeNG 11.3.2, if the issue persists please create a new ticket with a test case reproducing the issue e.g. stackblitz or a github repo and it will be reviewed by our team once again.

yigitfindikli avatar Apr 19 '21 07:04 yigitfindikli

i'm facing this exact same issue, although i don't have any further detail i can provide to this. I solved it by removing aot:true from angular.json... but only in development

jorgepazp avatar May 03 '21 20:05 jorgepazp

same issue here, using PrimeNG 11.2.0.

It just randomly started appearing yesterday without updating any dependencies or prime itself.

capc0 avatar May 14 '21 06:05 capc0

I understand that there's a dependency on PrimeNG 10 on Angular 10. I'm having the same issue, but I'm running PrimeNG 10 on Angular 10

jfuentesve avatar Dec 02 '21 21:12 jfuentesve

Thanks to Юлія Нечипорук, I enabled Ivy and the problem went away and the app started to work normally. I upgraded to Angular 10, PrimeNG 10 requires Angular 10.

The problem was related to enableIvy configuration. It is required to set it as 'true', otherwise, you won't be able to work with some of the animation-related components! – Юлія Нечипорук

jfuentesve avatar Dec 02 '21 21:12 jfuentesve