Repository navigation
fix(compiler-vapor): only treat html whitespace as empty slot content - #16161
simonkundrik wants to merge 1 commit into
Conversation
String.prototype.trim also strips NBSP, U+3000, U+FEFF and the other Unicode spaces, so an implicit default slot that only held one of them was dropped and the child rendered its fallback. Core only counts html whitespace here, so use the same check.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
A default slot that only holds a non-breaking space (or another Unicode space like U+3000) is treated as empty in vapor mode, so the child renders its fallback. In vdom the space is rendered.
vdom renders
<b> </b>and vapor renders<b>fallback</b>. When the child has no fallback, vapor renders nothing instead of the space, so something like<Button> </Button>or<Cell> </Cell>comes out empty.isNonWhitespaceContentincompiler-vapor/src/transforms/vSlot.tsusedString.prototype.trim(), which also strips NBSP, U+3000, U+FEFF and the other Unicode spaces. Core'sbuildSlotsusesisWhitespaceText, which only counts HTML whitespace. This switches it toisAllWhitespaceso the two agree. Explicit<template #default> </template>already worked.I added a parity test for
, , and. It fails onminorand passes with the change. Thecompiler-vaporandruntime-vaporunit suites pass, and so dotscand lint and format check on the changed files.Found by rendering random templates in both modes and diffing the DOM.