bug: Misleading console.error
when rendering components using internals
SSR
#6073
Closed
3 tasks done
Labels
Prerequisites
Stencil Version
4.22.3
Current Behavior
Currently, if a component has the
formAssociated
flag set and uses@AttachInternals()
, callingsetValidity
within thecomponentDidLoad
lifecycle method results in the followingconsole.error
message being logged:NOTE: Property form was accessed on...
This occurs because the underlying
MockElement
implementation proxies all calls tointernals
which callsconsole.error
. While this behavior might be reasonable in a testing environment—where it can serve as a helpful warning—it becomes irrelevant and misleading in server-side rendering (SSR) contexts.In SSR, such errors are unnecessary since the
ElementInternals
API does not apply in the server environment. Addressing this could involve conditionally suppressing these errors during SSR to avoid confusion and ensure a cleaner debugging experience.Expected Behavior
The
console.error
shouldn't be logged if the component is rendered in a SSR enviroment.System Info
Steps to Reproduce
See Description in dwirz/nextjs-stenciljs-example
Code Reproduction URL
https://github.com/dwirz/nextjs-stenciljs-example
Additional Information
Actually it is not a real bug, but it IMO the message should not be displayed if a component is rendered SSR because it is misleading.
The message comes from mock-doc/node.ts#L234
At the moment we add the following workaround check to each component which uses
internals
:The text was updated successfully, but these errors were encountered: