Skip to content
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

Remove DOM hooks from document #1

Merged
merged 2 commits into from
Apr 21, 2024
Merged

Remove DOM hooks from document #1

merged 2 commits into from
Apr 21, 2024

Conversation

barneycarroll
Copy link
Collaborator

The css-node elements are only there to get a hold of their parents, and they're just a liability after that (breaking positional structure like :only-child etc).

Tried to write a test to account for bug case but JSDOM wasn't playing ball and whatever TBH

lib/index.ts Outdated
if (options?.server) {
return
}

(vnode.dom as any).parentNode.classList.add(parsed.hash)
(parentNode as HTMLElement).classList.add(parsed.hash)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to remember in the past, removing this node caused mithril to get confused about the vtree state later on. It would try to unmount the node and then crash because the node wasn't there.

Maybe if we add a JSDOM test that unmounts the css node and see if mithril freaks out or not.

@@ -48,9 +48,6 @@ test('server', async () => {
assertStringEq(
pretty([...sheets.values()].join('')),
pretty(`
css-node {
display: none;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we still hide it for that short interval between first render and oncreate?

Copy link
Owner

@JAForbes JAForbes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested how this plays with super-mithril-hyperscript, but I like the idea of using text nodes, lets try it!

@JAForbes JAForbes merged commit 2e52e41 into master Apr 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants