-
-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function component returning null creates an empty text node in the DOM #1490
Labels
Comments
Empty text node is used to track position of Component with null children. Ideally we dont want to do this, but it fixes some issues. We could try remove that logic and see which test cases will fail |
Could using an HTML comment be a valid alternative? |
Yes, comment nodes could be used but they pollute DOM :( I need to check if same routines what we use for Fragments could be used to add support for not rendering anything. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue Template
Observed Behaviour
Inferno is creating an empty text node when a functional component returns
null
.Here, the
div
will have one children, an empty text node.Expected Current Behaviour
Inferno should not create anything.
null
, as from my understanding, means to put nothing in the DOM at all. Replacing the functional component with directly{null}
in the JSX actually does that (no text node at all).It's important because an empty text node can actually display some empty spacing if
line-height
is defined in the CSS on some browsers. I would not expect a component returningnull
to have any impact.Reproducing:
https://codesandbox.io/s/vigorous-browser-sw31e
Here is React rendering the same JSX code without any text node in both case:
https://codesandbox.io/s/admiring-water-o3exp
Inferno Metadata
macOS Chrome.
The text was updated successfully, but these errors were encountered: