Support » Plugin: Lazy Loader » Bug: doctype, html and body inserted into output

  • Resolved nichtsistwahr

    (@nichtsistwahr)


    Currently, the plugin adds a doctype and html+body tags to the content markup because DOMDocument thinks this is a good idea.

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html><body>

    It however should never ever be injected into the existing document.

    I tried altering this behaviour by adding options to loadHTML: LIBXML_HTML_NODEFDTD (which worked and got rid of the doctype) and LIBXML_HTML_NOIMPLIED (which did work, but also weirdly destroyed part of the post markup).

    I don’t really have time to debug this (the workaround above _should_ work and is probably the most elegant solution). What worked for me was to loop over the childNodes of the body element and save their HTML:

    $content = '';
    $bodyChildNodes = $dom->getElementsByTagName('body')[0]->childNodes;
    for ( $len = $bodyChildNodes->length, $i = 0; $i<$len; ++$i) {
      $content .= $dom->saveHTML( $bodyChildNodes->item($i) );
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    This should be fixed in the meanwhile.

    I am getting the stray doctype error on page validation as well.

    Error: Stray doctype.
    From line 16, column 6164; to line 16, column 6269
    t-entry”> <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN” “http://www.w3.org/TR/REC-html40/loose.dtd”><html&gt;
    Error: Stray start tag html.
    From line 16, column 6270; to line 16, column 6275
    oose.dtd”><html><body>
    Error: Start tag body seen but an element of the same type was already open.
    From line 16, column 6276; to line 16, column 6281
    td”><html><body><p sty

    I can start a new thread but thought I would post here.

    Anything I can do to prevent this?

    Thanks

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Can you post a link where I can take a look at the issue?

    Sure…

    GrantDB

    And any posts/pages with images.

    Thanks!

    I didn’t have the email notification for this post, sorry for the delay.

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    No problem πŸ™‚ Thanks for the link! Just noticed I can reproduce it on one of my pages too – it does not show up in the developer tools, so I did not notice it until now πŸ™ˆ

    Will take a look and release a new version as soon as possible!

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Uploaded the new version – silly mistake, I thought the SmartDomDocument class would overwrite the saveHTML() method from DomDocument to prevent the doctype, html, and body element gets added to the content, but it has its own saveHTMLExact() method… πŸ™ˆ

    Sweet! Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Bug: doctype, html and body inserted into output’ is closed to new replies.