diff options
-rw-r--r-- | src/HTML5/Parser/TreeBuildingRules.php | 11 | ||||
-rw-r--r-- | test/HTML5/Parser/TreeBuildingRulesTest.php | 11 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/HTML5/Parser/TreeBuildingRules.php b/src/HTML5/Parser/TreeBuildingRules.php index 0f1b3a5..b87c6b5 100644 --- a/src/HTML5/Parser/TreeBuildingRules.php +++ b/src/HTML5/Parser/TreeBuildingRules.php @@ -71,20 +71,19 @@ class TreeBuildingRules { case 'rp': return $this->handleRT($new, $current); case 'optgroup': - $this->closeIfCurrentMatches($new, $current, array('optgroup')); + return $this->closeIfCurrentMatches($new, $current, array('optgroup')); case 'option': - $this->closeIfCurrentMatches($new, $current, array('option', 'optgroup')); + return $this->closeIfCurrentMatches($new, $current, array('option', 'optgroup')); case 'tr': - $this->closeIfCurrentMatches($new, $current, array('tr')); + return $this->closeIfCurrentMatches($new, $current, array('tr')); case 'td': case 'th': - $this->closeIfCurrentMatches($new, $current, array('th', 'td')); + return $this->closeIfCurrentMatches($new, $current, array('th', 'td')); case 'tbody': case 'thead': case 'tfoot': case 'table': // Spec isn't explicit about this, but it's necessary. - $this->closeIfCurrentMatches($new, $current, array('thead', 'tfoot', 'tbody')); - + return $this->closeIfCurrentMatches($new, $current, array('thead', 'tfoot', 'tbody')); } return $current; diff --git a/test/HTML5/Parser/TreeBuildingRulesTest.php b/test/HTML5/Parser/TreeBuildingRulesTest.php index fe02893..a247cea 100644 --- a/test/HTML5/Parser/TreeBuildingRulesTest.php +++ b/test/HTML5/Parser/TreeBuildingRulesTest.php @@ -62,4 +62,15 @@ class TreeBuildingRulesTest extends \HTML5\Tests\TestCase { $this->assertEquals('dd', $list->lastChild->tagName); } + public function testTable() { + $html = sprintf(self::HTML_STUB, '<table><thead id="a"><th>foo<td>bar<td>baz'); + $doc = $this->parse($html); + + $list = $doc->getElementById('a'); + + $this->assertEquals(3, $list->childNodes->length); + $this->assertEquals('th', $list->firstChild->tagName); + $this->assertEquals('td', $list->lastChild->tagName); + } + } |