Skip to content

Commit 526c51d

Browse files
committed
fix(facades): fix splice semantics; add test
1 parent 2b4d30d commit 526c51d

5 files changed

Lines changed: 24 additions & 4 deletions

File tree

modules/angular2/src/facade/collection.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ class ListWrapper {
154154
static List slice(List l, int from, int to) {
155155
return l.sublist(from, to);
156156
}
157-
static List splice(List l, int from, int to) {
157+
static List splice(List l, int from, int length) {
158+
var to = from + length;
158159
var sub = l.sublist(from, to);
159160
l.removeRange(from, to);
160161
return sub;

modules/angular2/src/facade/collection.es6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ export class ListWrapper {
193193
static slice(l:List, from:int, to:int):List {
194194
return l.slice(from, to);
195195
}
196-
static splice(l:List, from:int, to:int):List {
197-
return l.splice(from, to);
196+
static splice(l:List, from:int, length:int):List {
197+
return l.splice(from, length);
198198
}
199199
static sort(l:List, compareFn:Function) {
200200
l.sort(compareFn);

modules/angular2/src/facade/collection.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ export class ListWrapper {
168168
return true;
169169
}
170170
static slice<T>(l: List<T>, from: int, to: int): List<T> { return l.slice(from, to); }
171+
static splice<T>(l:List<T>, from:int, length:int):List<T> {
172+
return l.splice(from, length);
173+
}
171174
static sort<T>(l: List<T>, compareFn: (a: T, b: T) => number) { l.sort(compareFn); }
172175
}
173176

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {describe, it, expect, beforeEach, ddescribe, iit, xit}
2+
from 'angular2/test_lib';
3+
4+
import {List, ListWrapper} from 'angular2/src/facade/collection';
5+
6+
export function main() {
7+
describe('ListWrapper', () => {
8+
describe('splice', () => {
9+
it('should remove sublist of given length and return it', () => {
10+
var list = [1, 2, 3, 4, 5, 6];
11+
expect(ListWrapper.splice(list, 1, 3)).toEqual([2, 3, 4]);
12+
expect(list).toEqual([1, 5, 6]);
13+
});
14+
});
15+
});
16+
}

modules/angular2_material/src/components/switcher/switch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class MdSwitch {
6565
}
6666

6767
onKeydown(event: KeyboardEvent) {
68-
if (event.keyCode == KEY_SPACE) {
68+
if (event.keyCode === KEY_SPACE) {
6969
event.preventDefault();
7070
this.toggle(event);
7171
}

0 commit comments

Comments
 (0)