@@ -30,47 +30,62 @@ export type View = (
3030 target : HTMLElement ,
3131 ) => void ;
3232
33+ function defaultView ( input : ViewInput , _ : unknown , target : HTMLElement ) : void {
34+ const [ firstEvaluation , ...intermediateEvaluations ] = input . evaluations ;
35+ render (
36+ // clang-format off
37+ html `
38+ < div class ="css-value-trace monospace ">
39+ ${ input . substitutions . map (
40+ line =>
41+ html `< span class ="trace-line-icon " aria-label ="is equal to "> ↳</ span
42+ > < span class ="trace-line "> ${ line } </ span > ` ,
43+ ) }
44+ ${ firstEvaluation && intermediateEvaluations . length === 0
45+ ? html `< span class ="trace-line-icon " aria-label ="is equal to "> ↳</ span
46+ > < span class ="trace-line "> ${ firstEvaluation } </ span > `
47+ : html `< details
48+ @toggle =${ input . onToggle }
49+ ?hidden =${ ! firstEvaluation ||
50+ intermediateEvaluations . length === 0 }
51+ >
52+ < summary >
53+ < span class ="trace-line-icon " aria-label ="is equal to "> ↳</ span
54+ > < devtools-icon class ="marker "> </ devtools-icon
55+ > < span class ="trace-line "> ${ firstEvaluation } </ span >
56+ </ summary >
57+ < div >
58+ ${ intermediateEvaluations . map (
59+ evaluation =>
60+ html `< span class ="trace-line-icon " aria-label ="is equal to "
61+ > ↳</ span
62+ > < span class ="trace-line "> ${ evaluation } </ span > ` ,
63+ ) }
64+ </ div >
65+ </ details > ` }
66+ ${ ! input . finalResult
67+ ? ''
68+ : html `< span class ="trace-line-icon " aria-label ="is equal to "> ↳</ span
69+ > < span class ="trace-line "> ${ input . finalResult } </ span > ` }
70+ </ div >
71+ ` ,
72+ // clang-format on
73+ target ,
74+ ) ;
75+ }
76+
3377export class CSSValueTraceView extends UI . Widget . VBox {
3478 #view: View ;
3579 #finalResult: Node [ ] | undefined = undefined ;
3680 #evaluations: Node [ ] [ ] = [ ] ;
3781 #substitutions: Node [ ] [ ] = [ ] ;
3882
39- constructor (
40- view : View = ( input , _ , target ) :
41- void => {
42- const substitutionIcon = html `< span class =trace-line-icon aria-label ="resolved to "> \u21B3</ span > ` ;
43- const evalIcon = html `< span class =trace-line-icon aria-label ="is equal to "> \u003D</ span > ` ;
44- const [ firstEvaluation , ...intermediateEvaluations ] = input . evaluations ;
45- render (
46- // clang-format off
47- html `
48- < div class ="css-value-trace monospace ">
49- ${ input . substitutions . map ( line => html `${ substitutionIcon } < span class ="trace-line "> ${ line } </ span > ` ) }
50- ${
51- firstEvaluation && intermediateEvaluations . length === 0
52- ? html `${ evalIcon } < span class ="trace-line "> ${ firstEvaluation } </ span > `
53- : html `< details
54- @toggle =${ input . onToggle }
55- ?hidden =${ ! firstEvaluation || intermediateEvaluations . length === 0 } >
56- < summary >
57- ${ evalIcon } < devtools-icon class =marker > </ devtools-icon > < span class ="trace-line "> ${ firstEvaluation } </ span >
58- </ summary >
59- < div >
60- ${ intermediateEvaluations . map ( evaluation => html `${ evalIcon } < span class ="trace-line "> ${ evaluation } </ span > ` ) }
61- </ div >
62- </ details > `
63- }
64- ${ ! input . finalResult ? '' : html `${ evalIcon } < span class ="trace-line "> ${ input . finalResult } </ span > ` }
65- </ div >
66- ` ,
67- // clang-format on
68- target ,
69- ) ;
70- } ,
71- ) {
83+ constructor ( view : View = defaultView ) {
7284 super ( true ) ;
73- this . registerRequiredCSS ( cssValueTraceViewStyles , stylePropertiesTreeOutlineStyles ) ;
85+ this . registerRequiredCSS (
86+ cssValueTraceViewStyles ,
87+ stylePropertiesTreeOutlineStyles ,
88+ ) ;
7489 this . #view = view ;
7590 this . requestUpdate ( ) ;
7691 }
0 commit comments