Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Mf2/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,9 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =

// Do we need to imply a name property?
// if no explicit "name" property, and no other p-* or e-* properties, and no nested microformats,
if (!array_key_exists('name', $return) && !in_array('p-', $prefixes) && !in_array('e-', $prefixes) && !$has_nested_mf && !$is_backcompat) {
if (!array_key_exists('name', $return) && !in_array('p-', $prefixes)
&& !in_array('e-', $prefixes) && !$has_nested_mf
&& !$is_backcompat && empty($this->upgraded[$e])) {
$name = false;
// img.h-x[alt] or area.h-x[alt]
if (($e->tagName === 'img' || $e->tagName === 'area') && $e->hasAttribute('alt')) {
Expand Down Expand Up @@ -1384,7 +1386,7 @@ public function parse_recursive(DOMElement $context = null, $depth = 0) {
$recurse = $this->parse_recursive($node, $depth + 1);

// set bool flag for nested mf
$has_nested_mf = ($recurse);
$has_nested_mf = (bool) $recurse;

// parse for root mf
$result = $this->parseH($node, $is_backcompat, $has_nested_mf);
Expand Down Expand Up @@ -1800,7 +1802,8 @@ public function query($expression, $context = null) {
'replace' => 'p-label'
),
'geo' => array(
'replace' => 'p-geo h-geo'
'replace' => 'p-geo h-geo',
'context' => 'geo'
),
'latitude' => array(
'replace' => 'p-latitude'
Expand Down
13 changes: 13 additions & 0 deletions tests/Mf2/ClassicMicroformatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -992,5 +992,18 @@ public function testBackcompatMultipleRoots() {
$this->assertContains('h-entry name', $result['items'][0]['properties']['name']);
}

/**
* @see https://github.com/microformats/php-mf2/issues/195
*/
public function testVcardGeoNoImpliedName() {
$input = '<div class="vcard">
<div class="fn">John Doe</div>
<div>Location: <abbr class="geo" title="30.267991;-97.739568">Brighton</abbr></div>
</div>';
$parser = new Parser($input, 'https://example.com');
$output = $parser->parse();

$this->assertArrayNotHasKey('name', $output['items'][0]['properties']['geo'][0]['properties']);
}
}