Merge "Use cloneWithData"

This commit is contained in:
jenkins-bot 2016-05-30 21:21:46 +00:00 committed by Gerrit Code Review
commit d5ad1d3ff8
3 changed files with 10 additions and 28 deletions

View file

@ -821,26 +821,12 @@ ve.dm.MWImageModel.prototype.getCurrentDimensions = function () {
*/
ve.dm.MWImageModel.prototype.getCaptionDocument = function () {
if ( !this.captionDoc ) {
this.captionDoc = new ve.dm.Document(
[
{ type: 'paragraph', internal: { generated: 'wrapper' } },
{ type: '/paragraph' },
{ type: 'internalList' },
{ type: '/internalList' }
],
// htmlDocument
this.parentDoc.getHtmlDocument(),
// parentDocument
null,
// internalList
null,
// innerWhitespace
null,
// lang
this.parentDoc.getLang(),
// dir
this.parentDoc.getDir()
);
this.captionDoc = this.parentDoc.cloneWithData( [
{ type: 'paragraph', internal: { generated: 'wrapper' } },
{ type: '/paragraph' },
{ type: 'internalList' },
{ type: '/internalList' }
] );
}
return this.captionDoc;
};

View file

@ -55,7 +55,8 @@ ve.ui.MWExtensionPreviewDialog.prototype.getSetupProcess = function ( data ) {
doc = this.selectedNode.getDocument().cloneFromRange( this.selectedNode.getOuterRange() );
} else {
element = this.getNewElement();
doc = new ve.dm.Document( [
// We assume that WindowAction pass
doc = data.fragment.getDocument().cloneWithData( [
element,
{ type: '/' + element.type },
{ type: 'internalList' },

View file

@ -1271,17 +1271,12 @@ ve.ui.MWMediaDialog.prototype.resetCaption = function () {
if ( this.imageModel ) {
captionDocument = this.imageModel.getCaptionDocument();
} else {
captionDocument = new ve.dm.Document( [
captionDocument = doc.cloneWithData( [
{ type: 'paragraph', internal: { generated: 'wrapper' } },
{ type: '/paragraph' },
{ type: 'internalList' },
{ type: '/internalList' }
],
// The ve.dm.Document constructor expects
// ( data, htmlDocument, parentDocument, internalList, innerWhitespace, lang, dir )
// as parameters. We are only interested in setting up language, hence the
// multiple 'null' values.
null, null, null, null, doc.getLang(), doc.getDir() );
] );
}
this.store = doc.getStore();