File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed
Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 3030
3131 const tippy = tippy_orig || noop;
3232
33-
3433 import Range from " ../Types/Range.svelte" ;
3534
3635 import formats from " ../Types/String/formats" ;
Original file line number Diff line number Diff line change 4444 {#if ref }
4545 <div >extends</div >
4646 <div >
47- <a href ={' # ' + relative_ref (ref )}>{ref }</a >
47+ <a href ={relative_ref (ref )}>{ref }</a >
4848
4949 {#if is_expanded_ref }
5050 <input on:click ={remove_ref } type =" button" value =" unexpand" />
157157 $: if (! id) id = href || " " ;
158158 $: if (id && ! id .includes (" #" )) id = id + " #" ;
159159
160+ $: if (href && ! href .includes (" #" )) {
161+ href = href + " #" ;
162+ }
160163 const fetch_ref = async () => {
161164 loading_ref = true ;
162165
181184
182185 function relative_ref (ref ) {
183186 if (ref .startsWith (" #" )) {
184- return id .replace (/ #. * / , " " ) + ref;
187+ console .log ({ ref, id });
188+ return " #" + id .replace (/ #. * / , " " ) + ref;
185189 }
186190
187- return ref;
191+ return " # " + ref;
188192 }
189193 </script >
190194
Original file line number Diff line number Diff line change 1+ const tap = require ( "../../tests/svelte_loader" ) ;
2+ import { render } from "@testing-library/svelte" ;
3+
4+ const Instance = require ( "./index.svelte" ) ;
5+
6+ const definition = {
7+ $id : "http://json-schema.org/draft-07/schema#" ,
8+ type : "object" ,
9+ properties : {
10+ allOf : { $ref : "#/definitions/schemaArray" } ,
11+ } ,
12+ } ;
13+
14+ const { container } = render ( Instance , { definition, href : definition . $id } ) ;
15+
16+ const links = Array . from ( container . querySelectorAll ( "a" ) ) . map ( ( a ) =>
17+ a . getAttribute ( "href" )
18+ ) ;
19+
20+ tap . equal (
21+ links [ 0 ] ,
22+ "#http://json-schema.org/draft-07/schema#/definitions/schemaArray" ,
23+ "relative definition link is properly resolved"
24+ ) ;
You can’t perform that action at this time.
0 commit comments