Index: trunk/parsers/wikidom/tests/hype/es.test.js |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | module( 'es' ); |
3 | 3 | |
4 | | -test( 'es.spliceArray', 1, function() { |
| 4 | +test( 'es.insertIntoArray', 1, function() { |
5 | 5 | var insert = [], i, arr = ['foo', 'bar'], expected = []; |
6 | 6 | expected[0] = 'foo'; |
7 | 7 | for ( i = 0; i < 3000; i++ ) { |
— | — | @@ -9,6 +9,6 @@ |
10 | 10 | } |
11 | 11 | expected[3001] = 'bar'; |
12 | 12 | |
13 | | - es.spliceArray( arr, 1, insert ); |
| 13 | + es.insertIntoArray( arr, 1, insert ); |
14 | 14 | deepEqual( arr, expected, 'splicing 3000 elements into the middle of a 2-element array' ); |
15 | 15 | } ); |
Index: trunk/parsers/wikidom/lib/hype/es.js |
— | — | @@ -28,8 +28,8 @@ |
29 | 29 | * |
30 | 30 | * @static |
31 | 31 | * @method |
32 | | - * @param dst {Function} Class to extend |
33 | | - * @param src {Function} Base class to use methods from |
| 32 | + * @param {Function} dst Class to extend |
| 33 | + * @param {Function} src Base class to use methods from |
34 | 34 | */ |
35 | 35 | es.extend = function( dst, src ) { |
36 | 36 | var base = new src(); |
— | — | @@ -49,9 +49,9 @@ |
50 | 50 | * |
51 | 51 | * @static |
52 | 52 | * @method |
53 | | - * @param a {Object} First object to compare |
54 | | - * @param b {Object} Second object to compare |
55 | | - * @param asymmetrical {Boolean} Whether to check only that b contains values from a |
| 53 | + * @param {Object} a First object to compare |
| 54 | + * @param {Object} b Second object to compare |
| 55 | + * @param {Boolean} [asymmetrical] Whether to check only that b contains values from a |
56 | 56 | * @returns {Boolean} If the objects contain the same values as each other |
57 | 57 | */ |
58 | 58 | es.compareObjects = function( a, b, asymmetrical ) { |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | * |
79 | 79 | * @static |
80 | 80 | * @method |
81 | | - * @param source {Array} Array to copy |
| 81 | + * @param {Array} source Array to copy |
82 | 82 | * @returns {Array} Copy of source array |
83 | 83 | */ |
84 | 84 | es.copyArray = function( source ) { |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | * |
103 | 103 | * @static |
104 | 104 | * @method |
105 | | - * @param source {Object} Object to copy |
| 105 | + * @param {Object} source Object to copy |
106 | 106 | * @returns {Object} Copy of source object |
107 | 107 | */ |
108 | 108 | es.copyObject = function( source ) { |
— | — | @@ -126,18 +126,18 @@ |
127 | 127 | * |
128 | 128 | * @static |
129 | 129 | * @method |
130 | | - * @param arr {Array} Array to splice insertion into. Will be modified |
131 | | - * @param offset {Number} Offset in arr to splice insertion in at. May be negative; see the 'index' parameter for Array.prototype.splice() |
132 | | - * @param insertion {Array} Array to insert |
| 130 | + * @param {Array} dst Array to splice insertion into. Will be modified |
| 131 | + * @param {Number} offset Offset in arr to splice insertion in at. May be negative; see the 'index' parameter for Array.prototype.splice() |
| 132 | + * @param {Array} src Array of items to insert |
133 | 133 | */ |
134 | | -es.spliceArray = function( arr, offset, insertion ) { |
| 134 | +es.insertIntoArray = function( dst, offset, src ) { |
135 | 135 | // We need to splice insertion in in batches, because of parameter list length limits which vary cross-browser. |
136 | 136 | // 1024 seems to be a safe batch size on all browsers. |
137 | 137 | var index = 0, batchSize = 1024; |
138 | | - while ( index < insertion.length ) { |
| 138 | + while ( index < src.length ) { |
139 | 139 | // Call arr.splice( offset, 0, i0, i1, i2, ..., i1023 ); |
140 | | - arr.splice.apply( |
141 | | - arr, [index + offset, 0].concat( insertion.slice( index, index + batchSize ) ) |
| 140 | + dst.splice.apply( |
| 141 | + dst, [index + offset, 0].concat( src.slice( index, index + batchSize ) ) |
142 | 142 | ); |
143 | 143 | index += batchSize; |
144 | 144 | } |
Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | // Remove the node we are about to insert into from the model tree |
70 | 70 | nodeParent.splice( index, 1 ); |
71 | 71 | // Perform insert on linear data model |
72 | | - es.spliceArray( this.data, this.cursor, op.data ); |
| 72 | + es.insertIntoArray( this.data, this.cursor, op.data ); |
73 | 73 | annotate.call( this, this.cursor + op.data.length ); |
74 | 74 | // Regenerate nodes for the data we've affected |
75 | 75 | var nodes = es.DocumentModel.createNodesFromData( |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | } |
82 | 82 | } else { |
83 | 83 | // Perform insert on linear data model |
84 | | - es.spliceArray( this.data, this.cursor, op.data ); |
| 84 | + es.insertIntoArray( this.data, this.cursor, op.data ); |
85 | 85 | annotate.call( this, this.cursor + op.data.length ); |
86 | 86 | // Update model tree |
87 | 87 | node.adjustContentLength( op.data.length ); |
— | — | @@ -796,7 +796,7 @@ |
797 | 797 | // We're inserting content into a structural location, |
798 | 798 | // so we need to wrap the inserted content in a paragraph. |
799 | 799 | insertedData = [ { 'type': 'paragraph' }, { 'type': '/paragraph' } ]; |
800 | | - es.spliceArray( insertedData, 1, data ); |
| 800 | + es.insertIntoArray( insertedData, 1, data ); |
801 | 801 | } else { |
802 | 802 | // Content being inserted in content is fine, do nothing |
803 | 803 | } |