273273 padding-left : 2em ;
274274 font-style : italic;
275275 }
276+ </ style >
277+ < script >
278+ ( function ( ) {
279+ function beforePrint ( ) {
280+ console . debug ( "opening details before printing" ) ;
281+ var algoDetails = document . querySelectorAll ( '.algorithm details' ) ;
282+ var c = 0 ;
283+ for ( var dt of algoDetails ) {
284+
285+ if ( ! dt . open ) {
286+ dt . setAttribute ( "data-was-closed" , "" ) ;
287+ dt . open = true ;
288+ c += 1 ;
289+ }
290+ }
291+ console . debug ( c , "details opended before printing" ) ;
292+ }
276293
277- /* required if we chose to put OLs *outside* the details,
278- to force them visible when printing */
279- @media screen {
280- .algorithm details : not ([open ]) + ol {
281- display : none;
294+ function afterPrint ( ) {
295+ console . debug ( "closing details after printing" ) ;
296+ var algoDetails = document . querySelectorAll ( '.algorithm details' ) ;
297+ var c = 0 ;
298+ for ( var dt of algoDetails ) {
299+ if ( dt . hasAttribute ( "data-was-closed" ) ) {
300+ dt . removeAttribute ( "data-was-closed" ) ;
301+ dt . open = false ;
302+ c += 1 ;
303+ }
304+ }
305+ console . debug ( c , "details closed after printing" ) ;
282306 }
283- }
284307
285- </ style >
308+ // using matchMedia
309+ window . matchMedia ( 'print' ) . addListener ( function ( mql ) {
310+ if ( mql . matches ) {
311+ beforePrint ( ) ;
312+ } else {
313+ afterPrint ( ) ;
314+ }
315+ } ) ;
316+ // using events
317+ window . addEventListener ( 'beforeprint' , beforePrint ) ;
318+ window . addEventListener ( 'afterprint' , afterPrint ) ;
319+ } ) ( ) ;
320+ </ script >
286321</ head >
287322
288323< body >
@@ -1143,8 +1178,7 @@ <h3>Algorithm</h3>
11431178 For each item < var > context</ var > in < var > local context</ var > :
11441179 < ol >
11451180 < li > If < var > context</ var > is < code > null</ code > :
1146- < details > < summary > clear context (unless protected)</ summary > </ details >
1147- < ol >
1181+ < details > < summary > clear context (unless protected)</ summary > < ol >
11481182 < li class ="changed "> If < var > override protected</ var > is < code > false</ code > and < var > active context</ var >
11491183 contains any < a > protected</ a > < a > term definitions</ a > ,
11501184 an < a data-link-for ="JsonLdErrorCode "> invalid context nullification</ a >
@@ -1157,7 +1191,7 @@ <h3>Algorithm</h3>
11571191 < span class ="note "> In [[[JSON-LD]]], the < a > base IRI</ a > was given
11581192 a default value here; this is now described conditionally
11591193 in < a href ="#the-application-programming-interface " class ="sectionRef "> </ a > .</ span > </ li >
1160- </ ol >
1194+ </ ol > </ details >
11611195 </ li >
11621196 < li > If < var > context</ var > is a < a > string</ a > :
11631197 < details > < summary > dereference and process</ summary > < ol >
0 commit comments