Skip to content

Commit f6bd656

Browse files
committed
[r96943502] chore: it does not render anchor if target ide is true
1 parent f766c5d commit f6bd656

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/components/ContentNode/SectionTitle.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
<template>
1212
<component
13-
:id="id"
13+
:id="!isTargetIDE ? id : null"
1414
:is="tag"
1515
class="section-title"
1616
>
1717
<a
18-
v-if="anchor"
18+
v-if="anchor && !isTargetIDE"
1919
:href="`#${anchor}`"
2020
class="header-anchor"
2121
aria-label="hidden"
@@ -46,6 +46,11 @@ export default {
4646
default: () => 'h2',
4747
},
4848
},
49+
inject: {
50+
isTargetIDE: {
51+
default: () => false,
52+
},
53+
},
4954
mounted() {
5055
if (!this.anchor) return;
5156
const element = document.getElementById(`${this.anchor}`);

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ describe('SectionTitle', () => {
3333
it('renders a section title with a header anchor and an id on the wrapper', async () => {
3434
const wrapper = shallowMount(SectionTitle, {
3535
propsData: {
36-
tag: 'h2',
3736
anchor: 'title',
3837
},
3938
slots: { default: 'Title' },
@@ -54,7 +53,6 @@ describe('SectionTitle', () => {
5453

5554
const wrapper = shallowMount(SectionTitle, {
5655
propsData: {
57-
tag: 'h2',
5856
anchor: 'title',
5957
},
6058
slots: { default: 'Title' },
@@ -70,4 +68,16 @@ describe('SectionTitle', () => {
7068
const wrapper = shallowMount(SectionTitle);
7169
expect(wrapper.find('.header-anchor').exists()).toBe(false);
7270
});
71+
72+
it('does not render anchor if target ide is true', () => {
73+
const wrapper = shallowMount(SectionTitle, {
74+
propsData: {
75+
anchor: 'title',
76+
},
77+
provide: {
78+
isTargetIDE: true,
79+
},
80+
});
81+
expect(wrapper.find('.header-anchor').exists()).toBe(false);
82+
});
7383
});

0 commit comments

Comments
 (0)