File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
src/components/ContentNode
tests/unit/components/ContentNode Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 10
10
11
11
<template >
12
12
<component
13
- :id =" id "
13
+ :id =" !isTargetIDE ? id : null "
14
14
:is =" tag"
15
15
class =" section-title"
16
16
>
17
17
<a
18
- v-if =" anchor"
18
+ v-if =" anchor && !isTargetIDE "
19
19
:href =" `#${anchor}`"
20
20
class =" header-anchor"
21
21
aria-label =" hidden"
@@ -46,6 +46,11 @@ export default {
46
46
default : () => ' h2' ,
47
47
},
48
48
},
49
+ inject: {
50
+ isTargetIDE: {
51
+ default : () => false ,
52
+ },
53
+ },
49
54
mounted () {
50
55
if (! this .anchor ) return ;
51
56
const element = document .getElementById (` ${ this .anchor } ` );
Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ describe('SectionTitle', () => {
33
33
it ( 'renders a section title with a header anchor and an id on the wrapper' , async ( ) => {
34
34
const wrapper = shallowMount ( SectionTitle , {
35
35
propsData : {
36
- tag : 'h2' ,
37
36
anchor : 'title' ,
38
37
} ,
39
38
slots : { default : 'Title' } ,
@@ -54,7 +53,6 @@ describe('SectionTitle', () => {
54
53
55
54
const wrapper = shallowMount ( SectionTitle , {
56
55
propsData : {
57
- tag : 'h2' ,
58
56
anchor : 'title' ,
59
57
} ,
60
58
slots : { default : 'Title' } ,
@@ -70,4 +68,16 @@ describe('SectionTitle', () => {
70
68
const wrapper = shallowMount ( SectionTitle ) ;
71
69
expect ( wrapper . find ( '.header-anchor' ) . exists ( ) ) . toBe ( false ) ;
72
70
} ) ;
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
+ } ) ;
73
83
} ) ;
You can’t perform that action at this time.
0 commit comments