From 4fcfbf3be7e7817a3e169a66f6b48bbc17a0bb0d Mon Sep 17 00:00:00 2001 From: Adrian Prayogo Date: Thu, 15 Dec 2016 17:05:46 +0800 Subject: [PATCH] fix: mountToJson not rendering mixed children (#34) * Fix mountToJson not rendering string text * fixup! Fix mountToJson not rendering string text --- src/mount.js | 4 +++ tests/core/__snapshots__/mount.test.js.snap | 40 +++++++++++++++++++++ tests/core/mount.test.js | 14 ++++++++ 3 files changed, 58 insertions(+) diff --git a/src/mount.js b/src/mount.js index ea37364..d2f64b4 100644 --- a/src/mount.js +++ b/src/mount.js @@ -10,6 +10,10 @@ function instToJson(inst) { if (typeof inst === 'string' || typeof inst === 'number') return inst; if (!inst) return ''; + if (inst._stringText) { + return inst._stringText; + } + if (!inst.getPublicInstance) { const internal = internalInstance(inst); return instToJson(internal); diff --git a/tests/core/__snapshots__/mount.test.js.snap b/tests/core/__snapshots__/mount.test.js.snap index 997f6aa..36e8850 100644 --- a/tests/core/__snapshots__/mount.test.js.snap +++ b/tests/core/__snapshots__/mount.test.js.snap @@ -139,6 +139,46 @@ exports[`test converts basic pure mount 1`] = ` `; +exports[`test converts class mount with mixed children 1`] = ` + +
+
+ + Hello + world + ! + + +
+
+
+`; + +exports[`test converts pure mount with mixed children 1`] = ` + +
+
+ + Hello + world + ! + + +
+
+
+`; + exports[`test skips undefined props 1`] = `