mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
26afa313f3
Five more defects in the example viewer, following #70508. The DOM was queried before Angular rendered it. `setCodeLinesVisibility()` walks the rendered lines but ran synchronously on tab change, so it measured the outgoing tab and the incoming file showed in full. The selected tab was also lost when the code block was hidden and reshown, because the recreated tab group had no `[selectedIndex]` while `snippetCode` survived, leaving the strip and the code disagreeing. `expandable` was computed once at startup by counting hidden DOM nodes, so a collapsed tab offered no way to expand it, and recomputing that count on tab change would drop the control whenever the block was expanded, since nothing is hidden then. Both paths now share one rule: a file is expandable when it has a `visibleLinesRange` and either the block is expanded or the range actually hides lines, so a range that covers its whole file still gets no inert control. Array indices were also mixed with 1-based line numbers: the gap check tested `index - 1` for the preceding line, drawing a `...` separator inside contiguous ranges, and the gutter tested `index` while the code tested `index + 1`, shifting every line number by one. Five new specs cover these, using the comma-separated range format the pipeline emits; each fails with its fix reverted. The tab label also moves from 0.8125rem to 0.875rem to match the code beside it.