Skip to content

Commit

Permalink
Revert "Updating DOMTemplate with outside fix, nothing important"
Browse files Browse the repository at this point in the history
This reverts commit 8964cef.
  • Loading branch information
Kroc committed Jun 29, 2012
1 parent 8964cef commit 37bad80
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/domtemplate/domtemplate.php
Expand Up @@ -283,8 +283,7 @@ public function addClass ($query, $new_class) {
} return $this;
}

//add a className to an existing class attribute
//(this is shared between `setValue` & `addClass`)
//add a className to an existing class attribute (this is shared between `setValue` & `addClass`
private function setClassNode ($DOMNode, $class) {
//check if the class node already has the className (don't add twice)
if (!in_array ($class, explode (' ', $DOMNode->nodeValue)))
Expand Down Expand Up @@ -419,17 +418,15 @@ public function __construct ($DOMNode, $namespaces=array ()) {
}

public function next () {
//reset the template
//(this is done first due to a segfault with PHP-FPM 5.3.10 which appears to dislike using `insertBefore`
// with a node that already exists within the template. thanks goes to Iain Dooley for discovering this bug)
$this->DOMNode = $this->template->cloneNode (true);
//when we insert the newly templated item, use it as the reference node for the next item and so on.
$this->refNode = ($this->refNode->parentNode->lastChild === $this->DOMNode)
? $this->refNode->parentNode->appendChild ($this->DOMNode)
//if there's some kind of HTML after the reference node, we can use that to insert our item
//inbetween. this means that the list you are templating doesn't have to be wrapped in an element!
: $this->refNode->parentNode->insertBefore ($this->DOMNode, $this->refNode->nextSibling)
;
//reset the template
$this->DOMNode = $this->template->cloneNode (true);
return $this;
}
}
Expand Down

0 comments on commit 37bad80

Please sign in to comment.