From da0a4b12e36380d216772ffe372adb862b669360 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Thu, 9 Mar 2023 17:17:56 -0500 Subject: [PATCH] Spec-related update See https://github.com/whatwg/html/pull/8271 Also removed test patches which are no longer needed, and fixed a bug exposed by new tests The testsuite includes tests for the new element, but this is not included in the specification yet, so the tests have been suppressed --- lib/Parser/Tokenizer.php | 2 +- lib/Parser/TreeConstructor.php | 6 +++--- tests/cases/TestTokenizer.php | 26 -------------------------- tests/cases/TestTreeConstructor.php | 21 +++++++++++++++++---- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/lib/Parser/Tokenizer.php b/lib/Parser/Tokenizer.php index e7f2828..0a65f4b 100644 --- a/lib/Parser/Tokenizer.php +++ b/lib/Parser/Tokenizer.php @@ -276,7 +276,7 @@ class Tokenizer { // DEVIATION: Character reference consumption implemented as a function $outChar = $this->switchToCharacterReferenceState(self::DATA_STATE); if (strspn($outChar, Data::WHITESPACE)) { - yield new WhitespaceToken($outChar); // a character reference is either all whitespace is no whitespace + yield new WhitespaceToken($outChar); // a character reference is either all whitespace or is not whitespace } else { yield new CharacterToken($outChar); } diff --git a/lib/Parser/TreeConstructor.php b/lib/Parser/TreeConstructor.php index 55926d2..556b24d 100644 --- a/lib/Parser/TreeConstructor.php +++ b/lib/Parser/TreeConstructor.php @@ -1076,7 +1076,7 @@ class TreeConstructor { # 2. Generate implied end tags. $this->stack->generateImpliedEndTags(); # 3. If the current node is not a form element, then this is a parse error. - if (!$this->stack->currentNodeName !== 'form') { + if ($this->stack->currentNodeName !== 'form') { $this->error(ParseError::UNEXPECTED_END_TAG, $token->name); } # 4. Pop elements from the stack of open elements until a form element has been @@ -2036,8 +2036,8 @@ class TreeConstructor { // mode as it may have been turned on in a previous evluation // of this mode $this->fosterParenting = false; - # A character token, if the current node is table, tbody, tfoot, thead, or tr element - if ($token instanceof CharacterToken && in_array($this->stack->currentNodeName, ["table", "tbody", "tfoot", "thead", "tr"])) { + # A character token, if the current node is table, tbody, template, tfoot, thead, or tr element + if ($token instanceof CharacterToken && in_array($this->stack->currentNodeName, ["table", "tbody", "template", "tfoot", "thead", "tr"])) { # Let the pending table character tokens be an empty list of tokens. $this->pendingTableCharacterTokens = []; # Let the original insertion mode be the current insertion mode. diff --git a/tests/cases/TestTokenizer.php b/tests/cases/TestTokenizer.php index 90a3a70..4f4d5e3 100644 --- a/tests/cases/TestTokenizer.php +++ b/tests/cases/TestTokenizer.php @@ -235,32 +235,6 @@ class TestTokenizer extends \PHPUnit\Framework\TestCase { case [" positions in some tests don't make sense - // https://github.com/html5lib/html5lib-tests/issues/125 - case ["", ["CDATA section state"]]: - // there is no position 2 - $test['errors'][0]['col']--; - break; - case ["\u{A}", ["CDATA section state"]]: - // the line break is, for some reason, not counted in the test - $test['errors'][0]['line']++; - $test['errors'][0]['col'] = 1; - break; - case ["