public function QueryPath::wrap in QueryPath 7.2
Same name and namespace in other branches
- 6 QueryPath/QueryPath.php \QueryPath::wrap()
- 7.3 QueryPath/QueryPath.php \QueryPath::wrap()
File
- QueryPath/
QueryPath.php, line 764
Class
Code
public function wrap($markup) {
$data = $this
->prepareInsert($markup);
if (empty($data)) {
return $this;
}
foreach ($this->matches as $m) {
$copy = $data->firstChild
->cloneNode(TRUE);
if ($copy
->hasChildNodes()) {
$deepest = $this
->deepestNode($copy);
$bottom = $deepest[0];
}
else {
$bottom = $copy;
}
$parent = $m->parentNode;
$parent
->insertBefore($copy, $m);
$m = $parent
->removeChild($m);
$bottom
->appendChild($m);
}
return $this;
}