jenkins-bot has submitted this change and it was merged. Change subject: DOMPostProcessor: Generate <head> only for the final document ......................................................................
DOMPostProcessor: Generate <head> only for the final document * Some minor code refactoring to make this more readable. Change-Id: Ide54116ca629e1d9083c053b4e691e6be700ff72 --- M lib/mediawiki.DOMPostProcessor.js 1 file changed, 36 insertions(+), 28 deletions(-) Approvals: Arlolra: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/mediawiki.DOMPostProcessor.js b/lib/mediawiki.DOMPostProcessor.js index 81db9da..9df34c0 100644 --- a/lib/mediawiki.DOMPostProcessor.js +++ b/lib/mediawiki.DOMPostProcessor.js @@ -233,34 +233,8 @@ return true; }; -DOMPostProcessor.prototype.doPostProcess = function( document ) { +DOMPostProcessor.prototype.addMetaData = function(document) { var env = this.env; - var psd = env.conf.parsoid; - - if (psd.dumpFlags && (psd.dumpFlags.indexOf("dom:post-builder") !== -1)) { - console.warn("---- DOM: after tree builder ----"); - dumpDOM({}, document.body); - console.warn("--------------------------------"); - } - - // holder for data-parsoid - if (env.storeDataParsoid) { - DU.setNodeData(document, { - parsoid: { - counter: -1, - ids: {} - } - }); - } - - for (var i = 0; i < this.processors.length; i++) { - try { - this.processors[i](document.body, this.env, this.options, this.atTopLevel); - } catch (e) { - env.log("fatal", e); - return; - } - } // add <head> element if it was missing if (!document.head) { @@ -384,8 +358,42 @@ document.body.classList.add('mw-body-content'); // Also add 'mediawiki' class document.body.classList.add('mediawiki'); +}; - this.emit( 'document', document ); +DOMPostProcessor.prototype.doPostProcess = function( document ) { + var psd = this.env.conf.parsoid; + if (psd.dumpFlags && (psd.dumpFlags.indexOf("dom:post-builder") !== -1)) { + console.warn("---- DOM: after tree builder ----"); + dumpDOM({}, document.body); + console.warn("--------------------------------"); + } + + // holder for data-parsoid + if (this.atTopLevel && this.env.storeDataParsoid) { + DU.setNodeData(document, { + parsoid: { + counter: -1, + ids: {} + } + }); + } + + for (var i = 0; i < this.processors.length; i++) { + try { + this.processors[i](document.body, this.env, this.options, this.atTopLevel); + } catch (e) { + this.env.log('fatal', e); + return; + } + } + + // For sub-pipeline documents, we are done. + // For the top-level document, we generate <head> and add it. + if (this.atTopLevel) { + this.addMetaData(document); + } + + this.emit('document', document); }; /** -- To view, visit https://gerrit.wikimedia.org/r/222735 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ide54116ca629e1d9083c053b4e691e6be700ff72 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org> Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: Cscott <canan...@wikimedia.org> Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org> Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits