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 @@ + cases/TestAttr.php cases/TestDocument.php cases/TestDocumentOrElement.php cases/TestDOMImplementation.php cases/TestDOMTokenList.php cases/TestElement.php + cases/TestInnerDocument.php cases/TestNode.php cases/TestParentNode.php diff --git a/vendor-bin/phpunit/composer.lock b/vendor-bin/phpunit/composer.lock index 6368d90..3986d6c 100644 --- a/vendor-bin/phpunit/composer.lock +++ b/vendor-bin/phpunit/composer.lock @@ -529,16 +529,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.9", + "version": "9.2.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b" + "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", - "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687", + "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687", "shasum": "" }, "require": { @@ -594,7 +594,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.9" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10" }, "funding": [ { @@ -602,20 +602,20 @@ "type": "github" } ], - "time": "2021-11-19T15:21:02+00:00" + "time": "2021-12-05T09:12:13+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "3.0.5", + "version": "3.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", - "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", "shasum": "" }, "require": { @@ -654,7 +654,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" }, "funding": [ { @@ -662,7 +662,7 @@ "type": "github" } ], - "time": "2020-09-28T05:57:25+00:00" + "time": "2021-12-02T12:48:52+00:00" }, { "name": "phpunit/php-invoker",