From b6c854be11c40e06cf874d89ff21c1e12f8f9e16 Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Wed, 17 Mar 2021 08:36:44 -0500 Subject: [PATCH] Finished off outerHTML --- lib/DOM/Element.php | 22 +++++++++++++++++++--- vendor-bin/phpunit/composer.lock | 12 ++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/DOM/Element.php b/lib/DOM/Element.php index 1e3acf7..25678b1 100644 --- a/lib/DOM/Element.php +++ b/lib/DOM/Element.php @@ -52,7 +52,10 @@ class Element extends \DOMElement { # 2.4 Extensions to the Element interface # outerHTML # - # On getting, return the result of invoking the fragment serializing algorithm on a fictional node whose only child is the context object providing true for the require well-formed flag (this might throw an exception instead of returning a string). + # On getting, return the result of invoking the fragment serializing algorithm + # on a fictional node whose only child is the context object providing true for + # the require well-formed flag (this might throw an exception instead of + # returning a string). // DEVIATION: Parsing of XML documents will not be handled by this // implementation, so there's no need for the well-formed flag. // OPTIMIZATION: When following the instructions above the fragment serializing @@ -120,7 +123,7 @@ class Element extends \DOMElement { // DEVIATION: Normally the tree mutation record would do the actual replacement, // but there is no scripting in this implementation. Going to simply append the // fragment instead. - $this->appendChild($ook); + $this->appendChild($frag); } break; @@ -145,7 +148,20 @@ class Element extends \DOMElement { throw new DOMException(DOMException::NO_MODIFICATION_ALLOWED); } # 4. parent is a DocumentFragment, let parent be a new Element with: + # • body as its local name, + # • The HTML namespace as its namespace, and + # • The context object's node document as its node document. + elseif ($parent instanceof DocumentFragment) { + $parent = $this->ownerDocument->createElement('body'); + } + + # 5. Let fragment be the result of invoking the fragment parsing algorithm with + # the new value as markup, and parent as the context element. + $fragment = Parser::parse($value, $this->ownerDocument, $this->ownerDocument->documentEncoding, $parent); + # 6. Replace the context object with fragment within the context object's + # parent. + $this->parentNode->replaceChild($fragment, $this); break; } } @@ -161,7 +177,7 @@ class Element extends \DOMElement { } // Since tag names can contain characters that are invalid in PHP's XML DOM - // uncoerce the name when printing. + // uncoerce the name when printing if necessary. if (strpos($tagName, 'U') !== false) { $tagName = $this->uncoerceName($tagName); } diff --git a/vendor-bin/phpunit/composer.lock b/vendor-bin/phpunit/composer.lock index d4db7fc..7ec4763 100644 --- a/vendor-bin/phpunit/composer.lock +++ b/vendor-bin/phpunit/composer.lock @@ -845,16 +845,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.2", + "version": "9.5.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f661659747f2f87f9e72095bb207bceb0f151cb4" + "reference": "27241ac75fc37ecf862b6e002bf713b6566cbe41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f661659747f2f87f9e72095bb207bceb0f151cb4", - "reference": "f661659747f2f87f9e72095bb207bceb0f151cb4", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/27241ac75fc37ecf862b6e002bf713b6566cbe41", + "reference": "27241ac75fc37ecf862b6e002bf713b6566cbe41", "shasum": "" }, "require": { @@ -932,7 +932,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.2" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.3" }, "funding": [ { @@ -944,7 +944,7 @@ "type": "github" } ], - "time": "2021-02-02T14:45:58+00:00" + "time": "2021-03-17T07:30:34+00:00" }, { "name": "sebastian/cli-parser",