diff --git a/Mf2/Parser.php b/Mf2/Parser.php
index 4506e62..350fcf0 100644
--- a/Mf2/Parser.php
+++ b/Mf2/Parser.php
@@ -1277,8 +1277,8 @@ public function parseRelsAndAlternates() {
$rel_attributes['type'] = $hyperlink->getAttribute('type');
}
- if ($hyperlink->nodeValue) {
- $rel_attributes['text'] = $hyperlink->nodeValue;
+ if (strlen($hyperlink->textContent) > 0) {
+ $rel_attributes['text'] = $hyperlink->textContent;
}
if ($this->enableAlternates) {
diff --git a/tests/Mf2/RelTest.php b/tests/Mf2/RelTest.php
index 2f34b23..2d737a2 100644
--- a/tests/Mf2/RelTest.php
+++ b/tests/Mf2/RelTest.php
@@ -209,4 +209,14 @@ public function testRelURLsNoDuplicates() {
$this->assertEquals($output['rels']['a'], array('#a', '#b'));
}
+ public function testRelURLsFalsyTextVSEmpty() {
+ $input = '0
+';
+ $parser = new Parser($input);
+ $output = $parser->parse();
+ $this->assertArrayHasKey('text', $output['rel-urls']['#a']);
+ $this->assertEquals($output['rel-urls']['#a']['text'], '0');
+ $this->assertArrayNotHasKey('text', $output['rel-urls']['#b']);
+ }
+
}