Skip to content

Commit f94472f

Browse files
committed
Render-blocking dark-theme initialization for dartdoc pages.
1 parent f4cf87f commit f94472f

33 files changed

+48
-0
lines changed

app/lib/dartdoc/dartdoc_page.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ extension DartDocPageRender on DartDocPage {
301301
'width': '0',
302302
'style': 'display:none;visibility:hidden',
303303
})),
304+
// NOTE: dartdoc's own initialization will still run, but it is not in conflict
305+
// with the current script.
306+
d.script(src: staticUrls.getAssetUrl('/static/js/dark-init.js')),
304307
d.div(id: 'overlay-under-drawer'),
305308
_renderHeader(options),
306309
_renderMain(options),

app/test/dartdoc/dartdoc_page_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ void main() {
185185
contains('https://www.googletagmanager.com/'));
186186
firstNoScript.remove();
187187

188+
// removing extra dark-theme initializer script
189+
renderedXmlDoc.descendantElements
190+
.where((e) =>
191+
e.localName == 'script' &&
192+
e.getAttribute('src')!.endsWith('/dark-init.js'))
193+
.single
194+
.remove();
195+
188196
// removing extra logo
189197
final firstLogo = renderedXmlDoc.descendantElements.firstWhere(
190198
(e) =>

app/test/task/testdata/goldens/documentation/oxygen/1.0.0/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</head>
2121
<body class="light-theme" data-base-href="" data-using-base-href="false">
2222
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
23+
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
2324
<div id="overlay-under-drawer"></div>
2425
<header id="title">
2526
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>

app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass-class.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</head>
2121
<body class="light-theme" data-base-href="../" data-using-base-href="false">
2222
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
23+
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
2324
<div id="overlay-under-drawer"></div>
2425
<header id="title">
2526
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>

app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/MainClass.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</head>
2121
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
2222
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
23+
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
2324
<div id="overlay-under-drawer"></div>
2425
<header id="title">
2526
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>

app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/text.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</head>
2121
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
2222
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
23+
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
2324
<div id="overlay-under-drawer"></div>
2425
<header id="title">
2526
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>

app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/toLowerCase.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</head>
2121
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
2222
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
23+
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
2324
<div id="overlay-under-drawer"></div>
2425
<header id="title">
2526
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>

app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/toString.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</head>
2121
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
2222
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
23+
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
2324
<div id="overlay-under-drawer"></div>
2425
<header id="title">
2526
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>

app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</head>
2121
<body class="light-theme" data-base-href="../" data-using-base-href="false">
2222
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
23+
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
2324
<div id="overlay-under-drawer"></div>
2425
<header id="title">
2526
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>

app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum/values-constant.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</head>
2121
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
2222
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
23+
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
2324
<div id="overlay-under-drawer"></div>
2425
<header id="title">
2526
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>

0 commit comments

Comments
 (0)