diff --git a/composer.lock b/composer.lock index e0c04ce..3f285a5 100644 --- a/composer.lock +++ b/composer.lock @@ -63,7 +63,7 @@ "source": { "type": "git", "url": "mensbeam-gitea:MensBeam/HTML-Parser.git", - "reference": "f33cc4344bf0138bed059af80cf896adcf4ee06d" + "reference": "a8435f7c358faaf39f9a0daa7f7a331a3e7cffca" }, "require": { "ext-dom": "*", @@ -130,7 +130,7 @@ "parsing", "whatwg" ], - "time": "2021-11-29T18:54:16+00:00" + "time": "2021-12-05T15:00:39+00:00" }, { "name": "mensbeam/intl", diff --git a/lib/DOMImplementation.php b/lib/DOMImplementation.php index 16a4659..8474811 100644 --- a/lib/DOMImplementation.php +++ b/lib/DOMImplementation.php @@ -35,7 +35,7 @@ class DOMImplementation { } - public function createDocument(?string $namespace = null, string $qualifiedName, ?DocumentType $doctype = null): XMLDocument { + public function createDocument(?string $namespace, string $qualifiedName, ?DocumentType $doctype = null): XMLDocument { # The createDocument(namespace, qualifiedName, doctype) method steps are: # # 1. Let document be a new XMLDocument. diff --git a/lib/Document.php b/lib/Document.php index f70cc27..d0c1c5c 100644 --- a/lib/Document.php +++ b/lib/Document.php @@ -110,7 +110,6 @@ class Document extends Node implements \ArrayAccess { foreach ($children as $child) { if ($child instanceof \DOMElement && $child->namespaceURI === null && $child->tagName === 'head') { return $this->innerNode->getWrapperNode($child); - break; } } } diff --git a/tests/cases/TestAttr.php b/tests/cases/TestAttr.php new file mode 100644 index 0000000..8665faa --- /dev/null +++ b/tests/cases/TestAttr.php @@ -0,0 +1,48 @@ +
', 'utf-8'); + $body = $d->body; + $svg = $d->getElementById('eek'); + $svg->setAttributeNS(Node::XMLNS_NAMESPACE, 'xmlns:xlink', Node::XLINK_NAMESPACE); + + // HTML name + $this->assertSame('ook', $body->getAttributeNode('ook')->name); + // Coerced name + $this->assertSame('poop💩', $body->getAttributeNode('poop💩')->name); + // Foreign attribute name + $this->assertSame('xlink', $svg->getAttributeNodeNS(Node::XMLNS_NAMESPACE, 'xlink')->name); + } + + public function testProperty_prefix(): void { + $d = new Document('', 'utf-8'); + $svg = $d->getElementById('eek'); + $svg->setAttributeNS(Node::XMLNS_NAMESPACE, 'xmlns:xlink', Node::XLINK_NAMESPACE); + $svg->setAttributeNS('https://poop.poop', 'poop💩:poop💩', 'poop💩'); + + // Foreign attribute name + $this->assertSame('xmlns', $svg->getAttributeNodeNS(Node::XMLNS_NAMESPACE, 'xlink')->prefix); + $this->assertSame('poop💩', $svg->getAttributeNodeNS('https://poop.poop', 'poop💩')->prefix); + } + + public function testProperty_specified(): void { + $d = new Document('', 'utf-8'); + $this->assertTrue($d->body->getAttributeNode('ook')->specified); + } +} \ No newline at end of file diff --git a/tests/cases/TestInnerDocument.php b/tests/cases/TestInnerDocument.php new file mode 100644 index 0000000..9b408b0 --- /dev/null +++ b/tests/cases/TestInnerDocument.php @@ -0,0 +1,45 @@ +assertSame(HTMLUnknownElement::class, $d->createElement('applet')::class); + $this->assertSame(HTMLElement::class, $d->createElement('noembed')::class); + $this->assertSame(HTMLPreElement::class, $d->createElement('xmp')::class); + $this->assertSame(HTMLPreElement::class, $d->createElement('pre')::class); + $this->assertSame(HTMLElement::class, $d->createElement('p-icon')::class); + } +} \ No newline at end of file diff --git a/tests/phpunit.dist.xml b/tests/phpunit.dist.xml index d686fa0..b25ef5e 100644 --- a/tests/phpunit.dist.xml +++ b/tests/phpunit.dist.xml @@ -16,11 +16,13 @@