Skip to content

Commit 50078b5

Browse files
committed
Merge branch 'master' of github.com:indieweb/php-mf2
2 parents 5940ed3 + eb22f33 commit 50078b5

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

Mf2/Parser.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,6 @@ public function parseH(\DOMElement $e, $is_backcompat = false) {
865865
continue;
866866
}
867867

868-
// In most cases, the value attribute of the nested microformat should be the p- parsed value of the elemnt.
869-
// The only times this is different is when the microformat is nested under certain prefixes, which are handled below.
870-
$result['value'] = $this->parseP($subMF);
871-
872868
// Does this µf have any property names other than h-*?
873869
$properties = nestedMfPropertyNamesFromElement($subMF);
874870

tests/Mf2/CombinedMicroformatsTest.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ public function testHCardChildHCard() {
195195
"properties": {
196196
"name": ["Mozilla Foundation"],
197197
"url": ["http://mozilla.org/"]
198-
},
199-
"value": "Mozilla Foundation"
198+
}
200199
}]
201200
}]
202201
}';
@@ -230,6 +229,9 @@ public function testMicroformatsNestedUnderEPropertyClassnamesRetainHtmlKey() {
230229
$input = '<div class="h-entry"><div class="h-card e-content"><p>Hello</p></div></div>';
231230
$mf = Mf2\parse($input);
232231

232+
$this->assertArrayHasKey('value', $mf['items'][0]['properties']['content'][0]);
233+
$this->assertEquals($mf['items'][0]['properties']['content'][0]['value'], 'Hello');
234+
$this->assertArrayHasKey('html', $mf['items'][0]['properties']['content'][0]);
233235
$this->assertEquals($mf['items'][0]['properties']['content'][0]['html'], '<p>Hello</p>');
234236
}
235237

@@ -299,4 +301,19 @@ public function testMicroformatsNestedUnderPPropertyClassnamesDeriveValueFromFir
299301

300302
$this->assertEquals($mf['items'][0]['properties']['author'][0]['value'], 'Zoe');
301303
}
304+
305+
306+
/**
307+
* @see https://github.com/indieweb/php-mf2/issues/98
308+
* @see https://github.com/microformats/tests/issues/58
309+
*/
310+
public function testNoValueForNestedMicroformatWithoutProperty() {
311+
$input = '<div class="h-card" ><a class="h-card" href="jane.html">Jane Doe</a><p></p></div>';
312+
$parser = new Parser($input);
313+
$output = $parser->parse();
314+
315+
$this->assertArrayHasKey('children', $output['items'][0]);
316+
$this->assertArrayNotHasKey('value', $output['items'][0]['children'][0]);
317+
}
318+
302319
}

0 commit comments

Comments
 (0)