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

Fix "Non-exhaustive patterns in function nodeOuterHtml" #1193

Merged
merged 2 commits into from
Nov 4, 2021

Conversation

neongreen
Copy link
Contributor

Fixes #1192.

Before this is merged, I'd love to know if there is also a testsuite for the client-side HTML patching code.

@@ -73,7 +73,7 @@ diffNodes' path Children { children = oldChildren } Children { children = newChi
patchElements (new:nextNewNode:newRest) (old:oldRest) !index | (not $ new `isNodeEqIgnoringPosition` old) && (old `isNodeEqIgnoringPosition` nextNewNode) = [ CreateNode { html = nodeOuterHtml new ?newHtml, path = (index:path) } ] <> (patchElements (newRest) (oldRest) (index + 2)) -- [A, C <old>] -> [A, B <new>, C <nextNewNode>]
patchElements (new:newRest) (old:nextOld:oldRest) !index | (not $ new `isNodeEqIgnoringPosition` old) && (new `isNodeEqIgnoringPosition` nextOld) = [ DeleteNode { node = old, path = (index:path) } ] <> (patchElements (newRest) (oldRest) (index + 1)) -- [A, B <old>, C <nextOldNode> ] -> [A, C <new>]
patchElements (new:newRest) (old:oldRest) !index = (diffNodes' (index:path) old new) <> (patchElements newRest oldRest (index + 1))
patchElements (new:newRest) oldRest !index = [ CreateNode { html = nodeOuterHtml new ?newHtml, path = (index:path) } ] <> (patchElements newRest oldRest (index + 1))
patchElements (new:newRest) [] !index = [ CreateNode { html = nodeOuterHtml new ?newHtml, path = (index:path) } ] <> (patchElements newRest [] (index + 1))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced with [] because it's always true and seems more informative.

@mpscholten
Copy link
Member

There's no test suite for the JS sadly

@neongreen
Copy link
Contributor Author

I tried it locally and it seems to work.

@mpscholten
Copy link
Member

Thanks! I could reproduce the issue and after apply the patch it was fixed 👍 Also didn't see anything that was broken after applying the patch

@mpscholten mpscholten merged commit 4348601 into digitallyinduced:master Nov 4, 2021
@neongreen neongreen deleted the fix-1192 branch November 4, 2021 18:31
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.

SSC: "Non-exhaustive patterns in function nodeOuterHtml"
2 participants