Skip to content

DOMPatch - #2

Draft
carson-katri wants to merge 3 commits into
iosfrom
ck/dom_patch
Draft

DOMPatch#2
carson-katri wants to merge 3 commits into
iosfrom
ck/dom_patch

Conversation

@carson-katri

Copy link
Copy Markdown
Member

No description provided.

end)
end

# def morphdom(from_node, to_node, opts \\ []) do

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This commented out section is an implementation I had started on that was more of a clone of the JS, but I abandoned it to get something working in a more functional style.

%{ node_type: @text_node, whole_text: from_whole_text } = from_child,
%{ node_type: @text_node, whole_text: to_whole_text } = _to_child
}, acc when from_whole_text != to_whole_text -> # text changed
GenDOM.Node.put(from_child, :whole_text, to_whole_text)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

try GenDOM.Node.put! I added that alternate form last week and it does a GenServer.cast instead of GenServer.call internally. This way you can update the state but avoid the blocking function call

on_before_node_discarded.(from_child)
on_before_node_added.(to_child)
# replace the child
GenDOM.Node.replace_child(from_node, to_child, from_child)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I should probably add bang versions of the DOM functions as well. There are a ton of fire-and-forget DOM manipulation calls in client that we don't need to block on

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