From bb330c0dad9534c7fae6fed9f8cbaf9d9774348c Mon Sep 17 00:00:00 2001 From: Adrian Helvik Date: Wed, 6 Nov 2019 17:23:07 +0100 Subject: [PATCH] Updated from buggy fragdom version --- package.json | 4 ++-- src/applyDiff.spec.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bf8117c..69079c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adrianhelvik/vdom", - "version": "1.3.7", + "version": "1.3.8", "main": "dist/index.js", "module": "src/index.js", "author": "Adrian Helvik ", @@ -33,6 +33,6 @@ ] }, "dependencies": { - "@adrianhelvik/fragdom": "^2.1.10" + "@adrianhelvik/fragdom": "^2.1.12" } } diff --git a/src/applyDiff.spec.js b/src/applyDiff.spec.js index bb356c9..a3de387 100644 --- a/src/applyDiff.spec.js +++ b/src/applyDiff.spec.js @@ -214,6 +214,29 @@ describe('on child elements', () => { expect(pending[0].target.parentNode.tagName).toBe('DIV') }) + + it('can replace a text node with false', () => { + const diffA = createDiff(null,
Hello
) + const diffB = createDiff(
Hello
,
{false}
) + + applyDiff(container, diffA) + applyDiff(container, diffB) + + expect(diffB).toEqual([{ type: 'replace node', node: false, path: [0, 0] }]) + + expect(fragContainer.debug().split('\n')).toEqual([ + /************************/ + '
', + '
', + ' <>', + '
', + '
', + ]) + + fragdomError(() => { + expect(container.innerHTML).toBe('
') + }) + }) }) it('can set initial props', () => { @@ -507,3 +530,12 @@ describe('replace child bugfix', () => { expect(root.innerHTML).toBe('Hello123') }) }) + +function fragdomError(fn) { + try { + fn() + } catch (e) { + e.message = `[Caused by Fragdom] ${e.message}` + throw e + } +}