Merge "Use static parseDocument method"

This commit is contained in:
jenkins-bot 2017-06-16 18:38:25 +00:00 committed by Gerrit Code Review
commit 4b852d899b
3 changed files with 10 additions and 10 deletions

View file

@ -21,12 +21,12 @@
}
}
target.originalDmDoc = target.constructor.static.createModelFromDom( target.parseDocument( oldHtml ), 'visual' );
target.originalDmDoc = target.constructor.static.createModelFromDom( target.constructor.static.parseDocument( oldHtml ), 'visual' );
surface.getModel().getDocument().getStore().merge( target.originalDmDoc.getStore() );
surface.getModel().getLinearFragment( new ve.Range( 0 ) ).insertDocument(
target.constructor.static.createModelFromDom( target.parseDocument( newHtml ), 'visual' )
target.constructor.static.createModelFromDom( target.constructor.static.parseDocument( newHtml ), 'visual' )
).collapseToEnd().adjustLinearSelection( 0, 3 ).removeContent();
target.once( 'saveReview', function () {

View file

@ -271,7 +271,7 @@ ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) {
this.etag = data.etag;
this.fromEditedState = data.fromEditedState;
this.switched = data.switched || 'wteswitched' in new mw.Uri( location.href ).query;
this.doc = this.parseDocument( this.originalHtml, this.getDefaultMode() );
this.doc = this.constructor.static.parseDocument( this.originalHtml, this.getDefaultMode() );
this.remoteNotices = ve.getObjectValues( data.notices );
this.protectedClasses = data.protectedClasses;
@ -1000,7 +1000,7 @@ ve.init.mw.ArticleTarget.prototype.onSaveDialogPreview = function () {
baseDoc = target.getSurface().getModel().getDocument().getHtmlDocument();
if ( ve.getProp( response, 'visualeditor', 'result' ) === 'success' ) {
doc = target.parseDocument( response.visualeditor.content, 'visual' );
doc = target.constructor.static.parseDocument( response.visualeditor.content, 'visual' );
body = doc.body;
// Import body to current document, then resolve attributes against original document (parseDocument called #fixBase)
document.adoptNode( body );
@ -1079,7 +1079,7 @@ ve.init.mw.ArticleTarget.prototype.getVisualDiffGeneratorPromise = function () {
).then( function ( response ) {
var doc, data = response ? ( response.visualeditor || response.visualeditoredit ) : null;
if ( data && typeof data.content === 'string' ) {
doc = target.parseDocument( data.content, 'visual' );
doc = target.constructor.static.parseDocument( data.content, 'visual' );
target.originalDmDoc = target.constructor.static.createModelFromDom( doc, 'visual' );
deferred.resolve( function () {
return new ve.dm.VisualDiff( target.originalDmDoc, dmDoc );

View file

@ -185,26 +185,26 @@ ve.init.mw.Target.prototype.createModelFromDom = function () {
return this.constructor.static.createModelFromDom.apply( this.constructor.static, arguments );
};
/* Methods */
/**
* @inheritdoc
*/
ve.init.mw.Target.prototype.parseDocument = function ( documentString, mode ) {
ve.init.mw.Target.static.parseDocument = function ( documentString, mode ) {
var doc;
if ( mode === 'source' ) {
// Parent method
doc = ve.init.mw.Target.super.prototype.parseDocument.apply( this, arguments );
doc = ve.init.mw.Target.super.static.parseDocument.apply( this, arguments );
} else {
// Parsoid documents are XHTML so we can use parseXhtml which fixed some IE issues.
doc = ve.parseXhtml( documentString );
}
// Fix relative or missing base URL if needed
this.constructor.static.fixBase( doc );
this.fixBase( doc );
return doc;
};
/* Methods */
/**
* Handle both DOM and modules being loaded and ready.
*