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