Address LaySite 1.4.5 editor and release review suggestions

This commit is contained in:
2026-11-27 22:14:02 +08:00
parent 00e8a70e06
commit 074591d34f
16 changed files with 159 additions and 48 deletions
+8 -3
View File
@@ -38,7 +38,9 @@ final class PageHead
continue;
}
if ($tag === 'script') {
$result['hasScript'] = true;
if (strtolower($attributes['type'] ?? '') !== 'application/ld+json') {
$result['hasScript'] = true;
}
if (!isset($attributes['src'])) {
$result['inlineScript'] = true;
$attributes['nonce'] = $nonce;
@@ -83,8 +85,11 @@ final class PageHead
|| ($node->nodeType === XML_TEXT_NODE && trim($node->textContent) === '')) {
continue;
}
if (!$node instanceof DOMElement || !isset(self::ATTRIBUTES[$node->tagName]) || count($entries) >= 40) {
throw new RuntimeException('Head 最多支持 40 个 meta、样式表、style 或 script 标签。');
if (!$node instanceof DOMElement || !isset(self::ATTRIBUTES[$node->tagName])) {
throw new RuntimeException('Head 仅支持 meta、样式表(link)、style 和 script 标签。');
}
if (count($entries) >= 40) {
throw new RuntimeException('Head 最多允许 40 个标签。');
}
$tag = $node->tagName;
$attributes = [];