Skip to content

Commit 20f618a

Browse files
committed
Return html-lang attribute only when it has a value
1 parent 6dbce79 commit 20f618a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Mf2/Parser.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -768,11 +768,17 @@ public function parseE(\DOMElement $e) {
768768
$html .= $node->ownerDocument->saveHTML($node);
769769
}
770770

771-
return array(
771+
$return = array(
772772
'html' => $html,
773773
'value' => unicodeTrim($this->innerText($e)),
774-
'html-lang' => $this->language($e)
775774
);
775+
776+
// Language
777+
if ( $html_lang = $this->language($e) ) {
778+
$return['html-lang'] = $html_lang;
779+
}
780+
781+
return $return;
776782
}
777783

778784
private function removeTags(\DOMElement &$e, $tagName) {
@@ -1031,7 +1037,9 @@ public function parseH(\DOMElement $e) {
10311037
}
10321038

10331039
// Language
1034-
$return['html-lang'] = $this->language($e);
1040+
if ( $html_lang = $this->language($e) ) {
1041+
$return['html-lang'] = $html_lang;
1042+
}
10351043

10361044
// Make sure things are in alphabetical order
10371045
sort($mfTypes);

0 commit comments

Comments
 (0)