如果我做:
let html = `<!DOCTYPE html>
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>`;
let newHTMLDocument = document.implementation.createHTMLDocument().documentElement;
newHTMLDocument.innerHTML = html;
console.log( newHTMLDocument );
输出是:
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
为什么不包含 doctype 标签?我需要做什么才能在输出 newHTMLDocument 时包含 doctype 标记?