[PATCH 6 of 6 V2] hgweb: add actual processing of ajax-received next page content

Alexander Plavin alexander at plav.in
Tue Aug 20 06:21:37 CDT 2013



20.08.2013, 13:38, "Laurens Holst" <laurens.nospam at grauw.nl>:
> Op 18-08-13 00:29, Alexander Plavin schreef:
>
>> # HG changeset patch # User Alexander Plavin <alexander at plav.in> # Date 1376754538 -14400 # Sat Aug 17 19:48:58 2013 +0400 # Node ID 12fcadea359e8df4d5c53cc0807acac00be38d02 # Parent 4b97b9c7034ef5d561021ce6f1f34a2f89764e7c hgweb: add actual processing of ajax-received next page content This code adds the received entries to the page. diff -r 4b97b9c7034e -r 12fcadea359e mercurial/templates/static/mercurial.js --- a/mercurial/templates/static/mercurial.js Sat Aug 17 15:35:40 2013 +0400 +++ b/mercurial/templates/static/mercurial.js Sat Aug 17 19:48:58 2013 +0400 @@ -362,6 +362,14 @@ function onstart() { }, function onsuccess(htmlText) { + var m = htmlText.match(nextHashRegex); + nextHash = m ? m[1] : null; + + var doc = docFromHTML(htmlText); + var nodes = doc.querySelector(containerSelector).children; + while (nodes.length) { + container.appendChild(nodes[0]); + }
>
> Just a note of warning, if this were XML this would be an illegal operation; you can’t just move nodes created by one document into another, it yields a WRONG_DOCUMENT_ERR. You have to call document. importNode(nodes[]) first.
>
> I guess for HTML it works though (as evidenced by your change), though I’m not sure whether this is standardised behaviour.

As I understand from JS specification, it's standardised for HTML documents, and the 'doc' variable always represents html document. Any evidences against?

>
> Also as htmlText does not contain a <body> tag as root element, you’re creating a document that does not have normal form (that is now standardised in HTML5, but nevertheless). Browsers may possibly insert <body> tags, etc.
>
> I think it’s better to just do createElement("div").innerHTML = ... in docFromHTML() to avoid these potential issues.

Ehm... Why do you think that there is no <body> in htmlText? It's full html page, the one that gets generated by hgweb now.

>
> ~Laurens


More information about the Mercurial-devel mailing list