Skip to content

Commit 14f184f

Browse files
authored
Merge pull request #1308 from mathjax/update/defs-position
Place the hidden svg/defs elements at the beginning of the document, not the end.
2 parents ae6aef4 + 82db2ae commit 14f184f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ts/handlers/html/HTMLDocument.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,16 @@ export class HTMLDocument<N, T, D> extends AbstractMathDocument<N, T, D> {
278278
* Add any elements needed for the document
279279
*/
280280
protected addPageElements() {
281-
const body = this.adaptor.body(this.document);
281+
const adaptor = this.adaptor;
282+
const body = adaptor.body(this.document);
282283
const node = this.documentPageElements();
283284
if (node) {
284-
this.adaptor.append(body, node);
285+
const child = adaptor.firstChild(body);
286+
if (child) {
287+
adaptor.insert(node, child);
288+
} else {
289+
adaptor.append(body, node);
290+
}
285291
}
286292
}
287293

0 commit comments

Comments
 (0)