Browse Source

Various minor corrections

ns
J. King 3 years ago
parent
commit
9758c08da2
  1. 13
      lib/TreeBuilder.php
  2. 4
      tests/cases/TestTreeConstructor.php

13
lib/TreeBuilder.php

@ -272,7 +272,7 @@ class TreeBuilder {
}
}
public function emitToken(Token $token) {
public function emitToken(Token $token): void {
assert((function() use ($token) {
$this->debugLog .= "EMITTED: ".constant(get_class($token)."::NAME")."\n";
return true;
@ -1520,9 +1520,11 @@ class TreeBuilder {
}
protected function parseTokenInForeignContent(Token $token): bool {
$currentNode = $this->stack->currentNode;
$currentNodeName = $this->stack->currentNodeName;
$currentNodeNamespace = $this->stack->currentNodeNamespace;
assert((function() {
$this->debugLog .= " Mode: Foreign content (".(string) $this->stack.")\n";
return true;
})());
# 13.2.6.5 The rules for parsing tokens in foreign content
#
# When the user agent is to apply the rules for parsing tokens in foreign
@ -1590,7 +1592,7 @@ class TreeBuilder {
do {
$popped = $this->stack->pop();
$n = $this->stack->currentNode;
$nns = $currentNode->namespaceURI;
$nns = $this->stack->currentNode->namespaceURI;
} while (!is_null($popped) && !(
$n->isMathMLTextIntegrationPoint()
|| $n->isHTMLIntegrationPoint()
@ -1604,6 +1606,7 @@ class TreeBuilder {
else {
// ¡TEMPORARY!
foreignContentAnyOtherStartTag:
$currentNodeNamespace = $this->stack->currentNodeNamespace;
# If the adjusted current node is an element in the SVG namespace, and the
# token’s tag name is one of the ones in the first column of the following
# table, change the tag name to the name given in the corresponding cell in the

4
tests/cases/TestTreeConstructor.php

@ -73,7 +73,7 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase {
$this->markTestSkipped('Requires implementation of the "Coercing an HTML DOM into an infoset" specification section');
return;
} catch (LoopException $e) {
$act = $this->serializeTree($doc);
$act = $this->serializeTree($doc, (bool) $fragmentContext);
$this->assertEquals($exp, $act, $e->getMessage()."\n".$treeBuilder->debugLog);
throw $e;
} catch (NotImplementedException $e) {
@ -105,7 +105,7 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase {
$this->out[] = "| ".str_repeat(" ", $this->depth).$data;
}
protected function serializeTree(\DOMDocument $d, bool $fragment): array {
protected function serializeTree(Document $d, bool $fragment): array {
$this->out = [];
$this->depth = 0;
if ($fragment){

Loading…
Cancel
Save