File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
src/Flow/Types/Type/Native/String
tests/Flow/Types/Tests/Unit/Value Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -126,8 +126,12 @@ public function isHTML() : bool
126126 $ options |= constant ('\Dom\HTML_NO_DEFAULT_NS ' );
127127 }
128128
129- HTMLDocument::createFromString ($ this ->string , $ options );
130- } elseif (\preg_match ('/(<!doctype(.+?)>)?<html(.+?)>(.+?)<\/html>/im ' , $ this ->string ) === 1 ) {
129+ $ doc = HTMLDocument::createFromString ($ this ->string , $ options );
130+
131+ return $ doc ->saveHtml () === $ this ->string ;
132+ }
133+
134+ if (\preg_match ('/(<!doctype(.+?)>)?<html(.+?)>(.+?)<\/html>/im ' , $ this ->string ) === 1 ) {
131135 try {
132136 \libxml_use_internal_errors (true );
133137
Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ final class HTMLDocumentTest extends TestCase
1414 #[RequiresPhp('>= 8.4 ' )]
1515 public function test_create_with_dom_document_html_on_newer () : void
1616 {
17- $ doc = \Dom \HTMLDocument::createFromString ('<html><body><div><span>bar</span></div></body></html> ' );
17+ $ doc = \Dom \HTMLDocument::createFromString ('<html><body><div><span>bar</span></div></body></html> ' , \ LIBXML_HTML_NOIMPLIED );
1818
1919 $ document = new HTMLDocument ($ doc );
2020
21- self ::assertSame ('<html><head></head>< body><div><span>bar</span></div></body></html> ' , (string ) $ document );
21+ self ::assertSame ('<html><body><div><span>bar</span></div></body></html> ' , (string ) $ document );
2222 }
2323
2424 #[RequiresPhp('<= 8.4 ' )]
You can’t perform that action at this time.
0 commit comments