hynky HF Staff commited on
Commit
cd54439
·
1 Parent(s): 76360d7
Files changed (1) hide show
  1. dist/index.html +8 -5
dist/index.html CHANGED
@@ -2,11 +2,14 @@
2
  // Block rendering until we ensure DOCTYPE is present
3
  if (document.doctype === null) {
4
  const doctypeNode = document.implementation.createDocumentType('html', '', '');
5
- if (document.firstChild) {
6
- document.insertBefore(doctypeNode, document.firstChild);
7
- } else {
8
- document.appendChild(doctypeNode);
9
- }
 
 
 
10
  }
11
  else {
12
  console.log('DOCTYPE is present');
 
2
  // Block rendering until we ensure DOCTYPE is present
3
  if (document.doctype === null) {
4
  const doctypeNode = document.implementation.createDocumentType('html', '', '');
5
+ document.insertBefore(doctypeNode, document.documentElement || document.firstChild);
6
+ // Force browser to reparse in standards mode
7
+ const htmlElement = document.documentElement;
8
+ const newHtmlElement = htmlElement.cloneNode(true);
9
+ htmlElement.parentNode.replaceChild(newHtmlElement, htmlElement);
10
+ // Force a reflow
11
+ void document.body.offsetWidth;
12
+ console.log('DOCTYPE is present');
13
  }
14
  else {
15
  console.log('DOCTYPE is present');