From 3a0ffafc7a55c5fc935b42f258a8ea4eeb0a6d32 Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Wed, 7 Apr 2021 23:35:16 -0500 Subject: [PATCH] Changed ElementRegistry to ElementMap, destructors for ElementMap --- README.md | 59 +----- lib/DOM/Comment.php | 2 +- lib/DOM/DOMException.php | 2 + lib/DOM/Document.php | 64 +----- lib/DOM/DocumentFragment.php | 2 +- lib/DOM/Element.php | 65 ++---- .../{ElementRegistry.php => ElementMap.php} | 12 +- lib/DOM/ProcessingInstruction.php | 2 +- lib/DOM/TemplateElement.php | 4 + lib/DOM/Text.php | 2 +- lib/DOM/traits/C14N.php | 18 -- lib/DOM/traits/Node.php | 191 ++++++++++++++++++ 12 files changed, 230 insertions(+), 193 deletions(-) rename lib/DOM/{ElementRegistry.php => ElementMap.php} (76%) delete mode 100644 lib/DOM/traits/C14N.php create mode 100644 lib/DOM/traits/Node.php diff --git a/README.md b/README.md index 282f879..f0bc15e 100644 --- a/README.md +++ b/README.md @@ -45,61 +45,4 @@ This library and [masterminds/html5](https://packagist.org/packages/masterminds/ † With HTML namespace disabled. With HTML namespace enabled it does not finish in a reasonable time due to a PHP bug. -‡ With parse errors suppressed. Reporting parse errors adds approximately 10% overhead. - -## Document Object Model ## - -This library works by parsing HTML strings into PHP's existing XML DOM. It, however, has to force the antiquated PHP DOM extension into working properly with modern HTML DOM by extending many of the node types. The documentation below follows PHP's doc style guide with the exception of inherited methods and properties not being listed. Therefore, only new constants, properties, and methods will be listed; in addition, extended methods which change outward behavior from their parent class will be listed. - -### MensBeam\\HTML\\Document ### - -```php -MensBeam\HTML\Document extends \DOMDocument { - - /* Constants */ - public const NO_QUIRKS_MODE = 0; - public const QUIRKS_MODE = 1; - public const LIMITED_QUIRKS_MODE = 2; - - /* Properties */ - public string|null $documentEncoding = null; - public int $quirksMode = 0; - - /* Methods */ - public load ( string $filename , null $options = null , string|null $encodingOrContentType = null ) : bool - public loadHTML ( string $source , null $options = null , string|null $encodingOrContentType = null ) : bool - public loadHTMLFile ( string $filename , null $options = null , string|null $encodingOrContentType = null ) : bool - public loadXML ( string $source , null $options = null ) : false - public save ( string $filename , null $options = null ) : int|false - public saveXML ( DOMNode|null $node = null , null $options = null ) : false - public validate ( ) : true - public xinclude ( null $options = null ) : false - -} -``` - -#### Properties #### - -
-
documentEncoding
-
Encoding of the document, as specified when parsing or when determining encoding type.
-
quirksMode
-
Used when parsing. Can be not in quirks mode, quirks mode, or limited quirks mode. See the `MensBeam\HTML\Document` constants to see the valid values.
-
- -The following properties inherited from `\DOMDocument` have no effect on `Mensbeam\HTML\Document`: - -* actualEncoding -* config -* encoding -* formatOutput -* preserveWhiteSpace -* recover -* resolveExternals -* standalone -* substituteEntities -* validateOnParse -* version -* xmlEncoding -* xmlStandalone -* xmlVersion \ No newline at end of file +‡ With parse errors suppressed. Reporting parse errors adds approximately 10% overhead. \ No newline at end of file diff --git a/lib/DOM/Comment.php b/lib/DOM/Comment.php index 5d8e66a..d492b0c 100644 --- a/lib/DOM/Comment.php +++ b/lib/DOM/Comment.php @@ -7,7 +7,7 @@ declare(strict_types=1); namespace MensBeam\HTML; class Comment extends \DOMComment { - use C14N, Moonwalk; + use Moonwalk, Node; public function __toString(): string { # Append the literal string "