Browse Source

Partial fixes for adoption agency

ns
J. King 3 years ago
parent
commit
fd01acfa5c
  1. 7
      lib/TreeBuilder.php
  2. 4
      tests/cases/TestTreeConstructor.php

7
lib/TreeBuilder.php

@ -3423,7 +3423,6 @@ class TreeBuilder {
$this->activeFormattingElementsList->removeSame($formattingElement); $this->activeFormattingElementsList->removeSame($formattingElement);
return; return;
} }
throw new NotImplementedException("NOT IMPLEMENTED");
# Let common ancestor be the element immediately above formatting element # Let common ancestor be the element immediately above formatting element
# in the stack of open elements. # in the stack of open elements.
$commonAncestor = $this->stack[$stackIndex - 1] ?? null; $commonAncestor = $this->stack[$stackIndex - 1] ?? null;
@ -3457,7 +3456,7 @@ class TreeBuilder {
# list of active formatting elements. # list of active formatting elements.
$nodeListPos = $this->activeFormattingElementsList->findSame($node); $nodeListPos = $this->activeFormattingElementsList->findSame($node);
if ($innerLoopCounter > 3 && $nodeListPos > -1) { if ($innerLoopCounter > 3 && $nodeListPos > -1) {
unset($this->activeFormattingElementsList[$nodeListPos]); $this->activeFormattingElementsList->removeSame($node);
if ($bookmark > $nodeListPos) { if ($bookmark > $nodeListPos) {
$bookmark--; $bookmark--;
} }
@ -3477,7 +3476,7 @@ class TreeBuilder {
# replace the entry for node in the stack of open elements with # replace the entry for node in the stack of open elements with
# an entry for the new element, and let node be the new element. # an entry for the new element, and let node be the new element.
$nodeToken = $this->activeFormattingElementsList[$nodeListPos]['token']; $nodeToken = $this->activeFormattingElementsList[$nodeListPos]['token'];
$element = $this->createElementForToken($token, null, $commonAncestor); $element = $this->createElementForToken($nodeToken, null, $commonAncestor);
$this->activeFormattingElementsList[$nodeListPos] = ['token' => $nodeToken, 'element' => $element]; $this->activeFormattingElementsList[$nodeListPos] = ['token' => $nodeToken, 'element' => $element];
$this->stack[$nodeIndex] = $element; $this->stack[$nodeIndex] = $element;
$node = $element; $node = $element;
@ -3522,7 +3521,7 @@ class TreeBuilder {
# elements, and insert the new element into the list of active # elements, and insert the new element into the list of active
# formatting elements at the position of the aforementioned bookmark. # formatting elements at the position of the aforementioned bookmark.
$this->activeFormattingElementsList->insert($formattingToken, $element, $bookmark); $this->activeFormattingElementsList->insert($formattingToken, $element, $bookmark);
unset($this->activeFormattingElementsList[$formattingElementIndex]); $this->activeFormattingElementsList->removeSame($formattingElement);
# Remove formatting element from the stack of open elements, and # Remove formatting element from the stack of open elements, and
# insert the new element into the stack of open elements # insert the new element into the stack of open elements
# immediately below the position of furthest block in that stack. # immediately below the position of furthest block in that stack.

4
tests/cases/TestTreeConstructor.php

@ -266,7 +266,7 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase {
} }
if (!$script) { if (!$script) {
// scripting-dependent tests are skipped entirely since we will not support scripting // scripting-dependent tests are skipped entirely since we will not support scripting
yield "$file #$index (line $pos)" => [$data, $exp, $errors, $fragment]; yield basename($file)." #$index (line $pos)" => [$data, $exp, $errors, $fragment];
} }
$l++; $l++;
$index++; $index++;
@ -274,4 +274,4 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase {
} }
} }
} }
} }

Loading…
Cancel
Save