From 2fcd6187357678678d0ee13e97f907059d46c7d6 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Sat, 8 Nov 2014 14:38:49 +0000 Subject: [PATCH] Allow itemref targets with itemscope to be traversed If the target element of an itemref has an itemscope attribute, it should still be traversed. --- src/MicrodataPhpDOMElement.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MicrodataPhpDOMElement.php b/src/MicrodataPhpDOMElement.php index fd3a9c3..46f448b 100644 --- a/src/MicrodataPhpDOMElement.php +++ b/src/MicrodataPhpDOMElement.php @@ -93,7 +93,7 @@ public function properties() { foreach ($this->itemRef() as $itemref) { $children = $this->ownerDocument->xpath()->query('//*[@id="'.$itemref.'"]'); foreach($children as $child) { - $this->traverse($child, $toTraverse, $props, $this); + $this->traverse($child, $toTraverse, $props, $this, true); } } while (count($toTraverse)) { @@ -169,7 +169,7 @@ protected function tokenList($string) { * See comment for MicrodataPhp:getObject() for an explanation of closure use * in this library. */ - protected function traverse($node, &$toTraverse, &$props, $root) { + protected function traverse($node, &$toTraverse, &$props, $root, $itemref = false) { foreach ($toTraverse as $i => $elem) { if ($elem->isSameNode($node)){ unset($toTraverse[$i]); @@ -181,7 +181,7 @@ protected function traverse($node, &$toTraverse, &$props, $root) { //@todo Add support for property name filtering. $props[] = $node; } - if ($node->itemScope()) { + if (!$itemref && $node->itemScope()) { return; } }