mediawiki-extensions-Visual.../modules/ve/dm/ve.dm.DocumentSlice.js
Trevor Parscal 29cdbe0ea5 (bug 42937) Removing copy/pasted link annotations removes the original as well
Basically a copy should be a deep copy, so this was a blatant mistake.

Change-Id: I702fb425783293c4ddde8b9ac568dfe6abc8f782
2012-12-10 18:12:55 -08:00

45 lines
1,007 B
JavaScript

/**
* VisualEditor data model DocumentSlice class.
*
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Document slice.
*
* @class
* @abstract
* @constructor
* @extends {ve.Node}
* @param {Array} data Balanced sliced data (will be deep copied internally)
* @param {ve.Range} [range] Original context within data
*/
ve.dm.DocumentSlice = function VeDmDocumentSlice( data, range ) {
// Properties
this.data = ve.copyArray( data );
this.range = range || new ve.Range( 0, data.length );
};
/* Methods */
/**
* Gets a deep copy the sliced data.
*
* @method
* @returns {Array} Document data
*/
ve.dm.DocumentSlice.prototype.getData = function () {
return this.data.slice( this.range.start, this.range.end );
};
/**
* Gets a balanced version of the sliced data.
*
* @method
* @returns {Array} Document data
*/
ve.dm.DocumentSlice.prototype.getBalancedData = function () {
return this.data.slice( 0 );
};