Commit more fixes

Some remaining failures are due to spec/test changes
This commit is contained in:
J. King 2021-10-04 13:46:52 -04:00
parent 2a470c1008
commit 4f2219edb7
2 changed files with 5 additions and 8 deletions

View file

@ -4195,17 +4195,13 @@ class TreeBuilder {
# Let local name be the tag name of the token.
# Let element be the result of creating an element given document,
# localName, given namespace, null, and is.
if ($token->name === "svg" && $namespace !== Parser::SVG_NAMESPACE) {
//var_export($namespace);
//exit;
}
try {
$element = $this->DOM->createElementNS($namespace, $token->name);
} catch (\DOMException $e) {
// The element name is invalid for XML
// Replace any offending characters with "UHHHHHH" where H are the
// uppercase hexadecimal digits of the character's code point
if ($namespace !== null) {
if ($namespace !== $this->htmlNamespace) {
$qualifiedName = implode(":", array_map([$this, "coerceName"], explode(":", $token->name, 2)));
} else {
$qualifiedName = $this->coerceName($token->name);

View file

@ -35,7 +35,7 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase {
protected $ns;
/** @dataProvider provideStandardTreeTests */
public function xtestStandardTreeTests(string $data, array $exp, array $errors, $fragment): void {
public function testStandardTreeTests(string $data, array $exp, array $errors, $fragment): void {
$this->runTreeTest($data, $exp, $errors, $fragment, null);
}
@ -82,7 +82,8 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase {
$fragment = explode(" ", $fragment);
assert(sizeof($fragment) < 3);
if (sizeof($fragment) === 1) {
$fragmentContext = $doc->createElement($fragment[0]);
// an HTML element
$fragmentContext = $doc->createElementNS($htmlNamespace, $fragment[0]);
} else {
$ns = array_flip(Parser::NAMESPACE_MAP)[$fragment[0]] ?? null;
assert(isset($ns));
@ -362,7 +363,7 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase {
$prefix = Parser::NAMESPACE_MAP[$e->namespaceURI];
assert((bool) $prefix, new \Exception("Prefix for namespace {$e->namespaceURI} is not defined"));
$prefix .= " ";
if ($this->ns) {
if ($this->ns && $prefix === "html ") {
// if the parser is using the HTML namespace on purpose, the prefix should be omitted
$prefix = "";
}