-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathHTML5DOMDocumentFragment.php
More file actions
47 lines (39 loc) · 1.16 KB
/
HTML5DOMDocumentFragment.php
File metadata and controls
47 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Masterminds\HTML5;
/**
* Keep the template-aware owner document alive for detached fragments.
*/
class HTML5DOMDocumentFragmentBase extends \DOMDocumentFragment
{
/**
* @var \DOMDocument|null
*/
protected $templateOwnerDocument;
/**
* @param \DOMDocument $document
*/
public function html5PhpKeepTemplateOwnerDocument(\DOMDocument $document)
{
$this->templateOwnerDocument = $document;
}
protected function html5PhpCloneNode($deep = false)
{
$clone = parent::cloneNode($deep);
if ($this->templateOwnerDocument instanceof \DOMDocument && method_exists($clone, 'html5PhpKeepTemplateOwnerDocument')) {
$clone->html5PhpKeepTemplateOwnerDocument($this->templateOwnerDocument);
}
TemplateContents::copySubtree($this, $clone, $deep);
return $clone;
}
}
if (PHP_VERSION_ID >= 80100) {
require __DIR__ . '/HTML5DOMDocumentFragment81.php';
} else {
class HTML5DOMDocumentFragment extends HTML5DOMDocumentFragmentBase
{
public function cloneNode($deep = false)
{
return $this->html5PhpCloneNode($deep);
}
}
}