Skip to content

Commit

Permalink
Update character encoding traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed May 18, 2015
1 parent fe41646 commit 0134d29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Dom/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function load($content = null) {

libxml_use_internal_errors(true);

$string = mb_convert_encoding(trim($string), "utf-8", "HTML-ENTITIES");
//$string = html_entity_decode($string, ENT_HTML5);
$this->domDocument->loadHTML($string);
}

Expand Down
20 changes: 19 additions & 1 deletion src/Dom/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class Node {
public $tagName;
public $classList;

public static $textReplacementArray = [
"." => ".",
];

/**
*
*/
Expand Down Expand Up @@ -138,6 +142,20 @@ public function __get($name) {
return html_entity_decode($innerHTML);
break;

case "textContent":
$textContent = $this->domNode->textContent;
$textContent = mb_convert_encoding(
$textContent,
"HTML-ENTITIES",
"UTF-8"
);
// foreach(self::$textReplacementArray as $search => $replace) {
// $textContent = str_replace($search, $replace, $textContent);
// }

return html_entity_decode($textContent, ENT_HTML5);
break;

case "previousElementSibling":
$sibling = $this;

Expand Down Expand Up @@ -200,7 +218,7 @@ public function __set($name, $value) {
case "textContent":
case "innerText":
case "text":
$value = htmlentities($value, ENT_COMPAT | ENT_HTML5);
$value = htmlentities($value, ENT_HTML5);
$this->domNode->nodeValue = $value;
break;

Expand Down

0 comments on commit 0134d29

Please sign in to comment.