Skip to content

Commit d6f8bfb

Browse files
authored
Remove accidental leading whitespace for certain captions. (#655)
Fixes an issue where captions without titles have an unnecessary leading whitespace character, which may slightly impact the alignment of the text. Resolves: rdar://109060293
1 parent 864361e commit d6f8bfb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/components/ContentNode/FigureCaption.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010

1111
<template>
1212
<figcaption class="caption" :class="{ centered }">
13-
<strong v-if="title">{{ title }}</strong>&nbsp;<slot />
13+
<template v-if="title">
14+
<strong>{{ title }}</strong>&nbsp;<slot />
15+
</template>
16+
<template v-else>
17+
<slot />
18+
</template>
1419
</figcaption>
1520
</template>
1621

tests/unit/components/ContentNode/FigureCaption.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ describe('FigureCaption', () => {
1818
const wrapper = shallowMount(FigureCaption, { propsData, slots });
1919

2020
expect(wrapper.is('figcaption')).toBe(true);
21-
expect(wrapper.text()).toMatch(/Figure 1\sBlah/);
21+
expect(wrapper.text()).toBe('Figure 1\u00a0Blah');
2222
});
23+
2324
it('renders a <figcaption> with slot content only', () => {
2425
const slots = { default: '<p>Blah</p>' };
2526
const wrapper = shallowMount(FigureCaption, { slots });
2627

2728
expect(wrapper.is('figcaption')).toBe(true);
2829
expect(wrapper.text()).toBe('Blah');
30+
expect(wrapper.text()).not.toBe('\u00a0Blah');
2931
});
3032

3133
it('renders a <figcaption> centered', () => {

0 commit comments

Comments
 (0)