Skip to content

Commit

Permalink
* Update to PHPHtmlParser 1.7.0
Browse files Browse the repository at this point in the history
* Version Bump to 1.3.6.2
  • Loading branch information
thampe committed Aug 30, 2016
1 parent cc9cd32 commit 257396b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 51 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hampe/inky",
"description": "PHP Implementation of ZURB's Foundation for Email parser (Inky)",
"version": "1.3.6.1",
"version": "1.3.6.2",
"license": "MIT",
"authors": [
{
Expand All @@ -19,6 +19,6 @@
},
"require": {
"php": ">=5.4.0",
"paquettg/php-html-parser": "^1.6"
"paquettg/php-html-parser": "^1.7"
}
}
20 changes: 15 additions & 5 deletions src/Inky.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
use Hampe\Inky\Component\RowFactory;
use Hampe\Inky\Component\SpacerFactory;
use Hampe\Inky\Component\WrapperFactory;
use Hampe\Inky\PHPHtmlParser\Dom;
use PHPHtmlParser\Dom;
use PHPHtmlParser\Dom\AbstractNode;
use PHPHtmlParser\Dom\Collection;
use PHPHtmlParser\Dom\HtmlNode;
use PHPHtmlParser\Dom\InnerNode;
use PHPHtmlParser\Exceptions\CircularException;

class Inky
Expand Down Expand Up @@ -183,6 +184,10 @@ protected function getAllComponentFactories()
public function releaseTheKraken($html)
{
$dom = new Dom();
$dom->setOptions([
'removeStyles' => false,
'removeScripts' => false,
]);
$dom->load((string) $html);

$parseCounter = 0;
Expand All @@ -196,14 +201,15 @@ public function releaseTheKraken($html)
return $dom->root->outerhtml;
}

protected function clearCache(AbstractNode $node)
protected function clearCache(InnerNode $node)
{
foreach($node->getChildren() as $child) {
if($child instanceof AbstractNode) {
$this->clearCache($child);
if($child instanceof InnerNode) {
$this->clearCache($child);
}
$node->removeChild($child->id());
$node->addChild($child);

}
}
}
Expand Down Expand Up @@ -237,7 +243,11 @@ protected function parse(Dom $dom)
$parseInComplete = true;
//replace element with new element
$parent = $element->getParent();
$siblings = $element->getParent()->getChildren();
if(!$parent instanceof InnerNode) {
continue;
}

$siblings = $parent->getChildren();
foreach($siblings as $sibling) {
/** @var $sibling HtmlNode*/
$parent->removeChild($sibling->id());
Expand Down
42 changes: 0 additions & 42 deletions src/PHPHtmlParser/Dom.php

This file was deleted.

6 changes: 5 additions & 1 deletion tests/Component/AbstractComponentFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


use Hampe\Inky\Inky;
use Hampe\Inky\PHPHtmlParser\Dom;
use PHPHtmlParser\Dom;

class AbstractComponentFactoryTest extends \PHPUnit_Framework_TestCase {

Expand All @@ -43,6 +43,10 @@ public function testParse()
foreach($this->testCases as $caseName => $testCase) {
$fromHtml = trim(preg_replace('~>\s+<~', '><', $testCase['from']));
$dom = new Dom();
$dom->setOptions([
'removeStyles' => false,
'removeScripts' => false,
]);
$dom->load((string) trim(preg_replace('~>\s+<~', '><', $testCase['to'])));
$toHtml = $dom->root->outerHtml();
$result = $inky->releaseTheKraken($fromHtml);
Expand Down
6 changes: 5 additions & 1 deletion tests/InkyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @date 13.03.16
*/

use Hampe\Inky\PHPHtmlParser\Dom;
use PHPHtmlParser\Dom;


class InkyTest extends PHPUnit_Framework_TestCase {
Expand Down Expand Up @@ -56,6 +56,10 @@ public function testStyles()
foreach($stylesTestCases as $caseName => $testCase) {
$fromHtml = trim(preg_replace('~>\s+<~', '><', $testCase['from']));
$dom = new Dom();
$dom->setOptions([
'removeStyles' => false,
'removeScripts' => false,
]);
$dom->load((string) trim(preg_replace('~>\s+<~', '><', $testCase['to'])));
$toHtml = $dom->root->outerHtml();
$result = $inky->releaseTheKraken($fromHtml);
Expand Down

0 comments on commit 257396b

Please sign in to comment.