@@ 81-111 (lines=31) @@ | ||
78 | /** |
|
79 | * @param \DOMNode|SimpleHtmlDomInterface|string $element HTML code or SimpleHtmlDomInterface, \DOMNode |
|
80 | */ |
|
81 | public function __construct($element = null) |
|
82 | { |
|
83 | $this->document = new \DOMDocument('1.0', $this->getEncoding()); |
|
84 | ||
85 | // reset |
|
86 | self::$domBrokenReplaceHelper = []; |
|
87 | ||
88 | // DOMDocument settings |
|
89 | $this->document->preserveWhiteSpace = true; |
|
90 | $this->document->formatOutput = true; |
|
91 | ||
92 | if ($element instanceof SimpleHtmlDomInterface) { |
|
93 | $element = $element->getNode(); |
|
94 | } |
|
95 | ||
96 | if ($element instanceof \DOMNode) { |
|
97 | $domNode = $this->document->importNode($element, true); |
|
98 | ||
99 | if ($domNode instanceof \DOMNode) { |
|
100 | /** @noinspection UnusedFunctionResultInspection */ |
|
101 | $this->document->appendChild($domNode); |
|
102 | } |
|
103 | ||
104 | return; |
|
105 | } |
|
106 | ||
107 | if ($element !== null) { |
|
108 | /** @noinspection UnusedFunctionResultInspection */ |
|
109 | $this->loadHtml($element); |
|
110 | } |
|
111 | } |
|
112 | ||
113 | /** |
|
114 | * @param string $name |
@@ 21-48 (lines=28) @@ | ||
18 | /** |
|
19 | * @param \DOMNode|SimpleXmlDomInterface|string $element HTML code or SimpleXmlDomInterface, \DOMNode |
|
20 | */ |
|
21 | public function __construct($element = null) |
|
22 | { |
|
23 | $this->document = new \DOMDocument('1.0', $this->getEncoding()); |
|
24 | ||
25 | // DOMDocument settings |
|
26 | $this->document->preserveWhiteSpace = true; |
|
27 | $this->document->formatOutput = true; |
|
28 | ||
29 | if ($element instanceof SimpleXmlDomInterface) { |
|
30 | $element = $element->getNode(); |
|
31 | } |
|
32 | ||
33 | if ($element instanceof \DOMNode) { |
|
34 | $domNode = $this->document->importNode($element, true); |
|
35 | ||
36 | if ($domNode instanceof \DOMNode) { |
|
37 | /** @noinspection UnusedFunctionResultInspection */ |
|
38 | $this->document->appendChild($domNode); |
|
39 | } |
|
40 | ||
41 | return; |
|
42 | } |
|
43 | ||
44 | if ($element !== null) { |
|
45 | /** @noinspection UnusedFunctionResultInspection */ |
|
46 | $this->loadXml($element); |
|
47 | } |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * @param string $name |