Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Imangazaliev committed Jan 5, 2016
1 parent ee61898 commit 1a12f43
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/DiDom/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ public function createElement($name, $value = '', $attributes = [])
*
* @throws \InvalidArgumentException if the provided argument is not an instance of \DOMNode or \DiDom\Element
*/
public function appendChild($element)
public function appendChild($node)
{
if ($element instanceof Element) {
$element = $element->getElement();
if ($node instanceof Element) {
$node = $node->getNode();
}

if (!$element instanceof DOMNode) {
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s\Element or %s, %s given', __METHOD__, __NAMESPACE__, 'DOMNode', (is_object($element) ? get_class($element) : gettype($element))));
if (!$node instanceof DOMNode) {
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s\Element or %s, %s given', __METHOD__, __NAMESPACE__, 'DOMNode', (is_object($node) ? get_class($node) : gettype($node))));
}

$cloned = $element->cloneNode(true);
$temp = $this->document->importNode($cloned, true);
$cloned = $node->cloneNode(true);
$newNode = $this->document->importNode($cloned, true);

$this->document->appendChild($temp);
$this->document->appendChild($newNode);

return $this;
}
Expand Down

0 comments on commit 1a12f43

Please sign in to comment.