11import { templates } from './components/templates.tpl'
22import { filterNotEmpty } from '../core/collections'
3- import { ApplyFormatters } from './formatters'
43import { localLanguage } from '../core/env'
54
6- const cache = { } //todo broken now!!
7-
85const lang = localLanguage ( )
96
10-
117function dateToString ( value ) {
128 const wiso = value . time
139 const prec = value . precision
@@ -99,7 +95,7 @@ function renderReferences(references) {
9995 ] )
10096}
10197
102- function renderQualifiers ( scope , delta ) {
98+ function renderQualifiers ( scope , delta , renderingCache : any ) {
10399 if ( ! ( scope === 'statement' && typeof delta != 'undefined' && delta . hasOwnProperty ( 'qualifiers' ) ) ) {
104100 return [ ]
105101 }
@@ -109,7 +105,7 @@ function renderQualifiers(scope, delta) {
109105 const qvalues = [ ]
110106 for ( const qv of delta . qualifiers [ prop ] ) {
111107 const qualvalue = new DocumentFragment ( )
112- qualvalue . append ( ...renderStatements ( qv , [ ] , qv . snaktype , 'qualifier' , undefined ) )
108+ qualvalue . append ( ...renderStatements ( qv , [ ] , qv . snaktype , 'qualifier' , undefined , renderingCache ) )
113109 qvalues . push ( qualvalue )
114110 }
115111
@@ -130,7 +126,7 @@ function renderIdLinks(valueType, snak) {
130126 return [ ]
131127}
132128
133- function renderStatementCore ( snak , type , scope , valueType ) {
129+ function renderStatementCore ( snak , type , scope , valueType , renderingCache : any ) {
134130 if ( type === 'preformatted' ) {
135131 return [ snak . datavalue . value ]
136132 }
@@ -147,7 +143,7 @@ function renderStatementCore(snak, type, scope, valueType) {
147143 const vid = snak . datavalue . value . id
148144 return filterNotEmpty ( [
149145 snak . datavalue . parents ? templates . breadcrumbsPlaceholder ( snak . datavalue . parents ) : null ,
150- templates . placeholder ( { entity : vid } , cache ) ,
146+ templates . placeholder ( { entity : vid } , renderingCache ) ,
151147 ] )
152148 }
153149 if ( valueType === 'external-id' ) {
@@ -214,13 +210,13 @@ function renderStatementCore(snak, type, scope, valueType) {
214210 return [ ]
215211}
216212
217- export function renderStatements ( snak , references , type , scope , delta ) {
213+ export function renderStatements ( snak , references , type , scope , delta , renderingCache : any ) {
218214 const valueType = snak . datatype ? snak . datatype : snak . datavalue . type
219215 return [
220- ...renderStatementCore ( snak , type , scope , valueType ) ,
216+ ...renderStatementCore ( snak , type , scope , valueType , renderingCache ) ,
221217 ...renderReferences ( references ) ,
222218 ...renderIdLinks ( valueType , snak ) ,
223- ...renderQualifiers ( scope , delta ) ,
219+ ...renderQualifiers ( scope , delta , renderingCache ) ,
224220 ]
225221}
226222
@@ -234,7 +230,7 @@ export interface Claim {
234230 // todo improve
235231}
236232
237- export function renderStatement ( claims : Claim [ ] ) {
233+ export function renderStatement ( claims : Claim [ ] , renderingCache : any ) {
238234 if ( ! claims [ 0 ] ?. mainsnak ) return
239235
240236 const pid = claims [ 0 ] . mainsnak . property
@@ -253,15 +249,15 @@ export function renderStatement(claims: Claim[]) {
253249 }
254250 }
255251
256- thisvalue . append ( ...renderStatements ( delta . mainsnak , refs , type , 'statement' , delta ) )
252+ thisvalue . append ( ...renderStatements ( delta . mainsnak , refs , type , 'statement' , delta , renderingCache ) )
257253 values . push ( thisvalue )
258254
259255 }
260256 }
261257 const statement = templates . remark ( {
262258 prop : templates . placeholder ( {
263259 entity : pid ,
264- } , cache ) ,
260+ } , renderingCache ) ,
265261 vals : values ,
266262 id : pid ,
267263 } )
0 commit comments