Add ownerDocument attribute to nodes
parent
987308fc0a
commit
fbdf1aa414
|
@ -21,8 +21,22 @@ class ReferencesAdder extends NodeVisitorAbstract
|
|||
*/
|
||||
private $previous;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $document;
|
||||
|
||||
/**
|
||||
* @param mixed $document The value for the ownerDocument attribute
|
||||
*/
|
||||
public function __construct($document = null)
|
||||
{
|
||||
$this->document = $document;
|
||||
}
|
||||
|
||||
public function enterNode(Node $node)
|
||||
{
|
||||
$node->setAttribute('ownerDocument', $this->document);
|
||||
if (!empty($this->stack)) {
|
||||
$node->setAttribute('parentNode', end($this->stack));
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ class PhpDocument
|
|||
$traverser->addVisitor(new NameResolver);
|
||||
|
||||
// Add parentNode, previousSibling, nextSibling attributes
|
||||
$traverser->addVisitor(new ReferencesAdder);
|
||||
$traverser->addVisitor(new ReferencesAdder($this));
|
||||
|
||||
// Add column attributes to nodes
|
||||
$traverser->addVisitor(new ColumnCalculator($this->content));
|
||||
|
|
Loading…
Reference in New Issue