Skip to content

Commit 1666883

Browse files
committed
chore(browsers): fix failing tests in IE11
Closes angular#3388
1 parent 39ad506 commit 1666883

File tree

6 files changed

+54
-48
lines changed

6 files changed

+54
-48
lines changed

modules/angular2/src/dom/browser_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
121121
}
122122
firstChild(el): Node { return el.firstChild; }
123123
nextSibling(el): Node { return el.nextSibling; }
124-
parentElement(el): Node { return el.parentElement; }
124+
parentElement(el): Node { return el.parentNode; }
125125
childNodes(el): List<Node> { return el.childNodes; }
126126
childNodesAsList(el): List<any> {
127127
var childNodes = el.childNodes;

modules/angular2/src/test_lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function containsRegexp(input: string): RegExp {
3535
export function normalizeCSS(css: string): string {
3636
css = StringWrapper.replaceAll(css, /\s+/g, ' ');
3737
css = StringWrapper.replaceAll(css, /:\s/g, ':');
38-
css = StringWrapper.replaceAll(css, /'"/g, '"');
38+
css = StringWrapper.replaceAll(css, /'/g, '"');
3939
css = StringWrapper.replaceAllMapped(css, /url\(\"(.+)\\"\)/g, (match) => `url(${match[1]})`);
4040
css = StringWrapper.replaceAllMapped(css, /\[(.+)=([^"\]]+)\]/g,
4141
(match) => `[${match[1]}="${match[2]}"]`);

modules/angular2/test/core/zone/ng_zone_spec.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function commonTests() {
182182
macroTask(() => {
183183
expect(_log.result()).toEqual('run; onTurnDone 1; onTurnDone 2; onEventDone');
184184
async.done();
185-
});
185+
}, 80);
186186
}));
187187

188188
it('should not allow onEventDone to cause further digests',
@@ -206,7 +206,7 @@ function commonTests() {
206206
macroTask(() => {
207207
expect(_log.result()).toEqual('run; onTurnDone; onEventDone');
208208
async.done();
209-
});
209+
}, 80);
210210
}));
211211

212212
it('should run async tasks scheduled inside onEventDone outside Angular zone',
@@ -247,7 +247,7 @@ function commonTests() {
247247
// The microtask (async) is executed after the macrotask (run)
248248
expect(_log.result()).toEqual('onTurnStart; run start; run end; async; onTurnDone');
249249
async.done();
250-
}, 50);
250+
}, 80);
251251
}));
252252

253253
it('should not run onTurnStart and onTurnDone for nested Zone.run',
@@ -268,7 +268,7 @@ function commonTests() {
268268
.toEqual(
269269
'onTurnStart; start run; nested run; end run; nested run microtask; onTurnDone');
270270
async.done();
271-
}, 50);
271+
}, 80);
272272
}));
273273

274274
it('should not run onTurnStart and onTurnDone for nested Zone.run invoked from onTurnDone',
@@ -286,7 +286,7 @@ function commonTests() {
286286
expect(_log.result())
287287
.toEqual('start run; onTurnDone:started; nested run; onTurnDone:finished');
288288
async.done();
289-
}, 50);
289+
}, 80);
290290
}));
291291

292292
it('should call onTurnStart and onTurnDone before and after each top-level run',
@@ -330,7 +330,7 @@ function commonTests() {
330330
.toEqual(
331331
'onTurnStart; run start; onTurnDone; onTurnStart; a then; b then; onTurnDone');
332332
async.done();
333-
}, 50);
333+
}, 80);
334334
}));
335335

336336
it('should run a function outside of the angular zone',
@@ -370,7 +370,7 @@ function commonTests() {
370370
// Third VM Turn => execute the microtask (inside angular)
371371
'onTurnStart; executedMicrotask; onTurnDone');
372372
async.done();
373-
}, 50);
373+
}, 80);
374374
}));
375375

376376
it('should call onTurnStart before executing a microtask scheduled in onTurnDone as well as ' +
@@ -400,7 +400,7 @@ function commonTests() {
400400
// Second VM Turn => microtask enqueued from onTurnDone
401401
'onTurnStart; executedMicrotask; onTurnDone(begin); onTurnDone(end)');
402402
async.done();
403-
}, 50);
403+
}, 80);
404404
}));
405405

406406
it('should call onTurnStart and onTurnDone for a scheduleMicrotask in onTurnDone triggered by ' +
@@ -435,7 +435,7 @@ function commonTests() {
435435
// Second VM Turn => the microtask enqueued from onTurnDone
436436
'onTurnStart; onTurnDone(executeMicrotask); onTurnDone(begin); onTurnDone(end)');
437437
async.done();
438-
}, 50);
438+
}, 80);
439439
}));
440440

441441
it('should execute promises scheduled in onTurnStart before promises scheduled in run',
@@ -490,7 +490,7 @@ function commonTests() {
490490
// Second VM turn: execute the microtask from onTurnEnd
491491
'onTurnStart(begin); onTurnStart(end); onTurnDone(executePromise); onTurnDone(begin); onTurnDone(end)');
492492
async.done();
493-
}, 50);
493+
}, 80);
494494
}));
495495

496496
it('should call onTurnStart and onTurnDone before and after each turn, respectively',
@@ -508,10 +508,10 @@ function commonTests() {
508508
});
509509
});
510510

511-
macroTask(() => { _zone.run(() => { completerA.resolve(null); }); }, 10);
511+
macroTask(() => { _zone.run(() => { completerA.resolve(null); }); }, 20);
512512

513513

514-
macroTask(() => { _zone.run(() => { completerB.resolve(null); }); }, 30);
514+
macroTask(() => { _zone.run(() => { completerB.resolve(null); }); }, 40);
515515

516516
macroTask(() => {
517517
expect(_log.result())
@@ -523,7 +523,7 @@ function commonTests() {
523523
// Third VM turn
524524
'onTurnStart; b then; onTurnDone');
525525
async.done();
526-
}, 60);
526+
}, 80);
527527
}));
528528

529529
it('should call onTurnStart and onTurnDone before and after (respectively) all turns in a chain',
@@ -543,7 +543,7 @@ function commonTests() {
543543
expect(_log.result())
544544
.toEqual('onTurnStart; run start; run end; async1; async2; onTurnDone');
545545
async.done();
546-
}, 50);
546+
}, 80);
547547
}));
548548

549549
it('should call onTurnStart and onTurnDone for promises created outside of run body',
@@ -565,7 +565,7 @@ function commonTests() {
565565
expect(_log.result())
566566
.toEqual('onTurnStart; zone run; onTurnDone; onTurnStart; promise then; onTurnDone');
567567
async.done();
568-
}, 50);
568+
}, 80);
569569
}));
570570
});
571571

@@ -596,7 +596,7 @@ function commonTests() {
596596
expect(_errors.length).toBe(1);
597597
expect(_errors[0]).toEqual(exception);
598598
async.done();
599-
}, 50);
599+
}, 80);
600600
}));
601601

602602
it('should call onError when onTurnDone throws and the zone is sync',
@@ -612,7 +612,7 @@ function commonTests() {
612612
expect(_errors.length).toBe(1);
613613
expect(_errors[0]).toEqual(exception);
614614
async.done();
615-
}, 50);
615+
}, 80);
616616
}));
617617

618618
it('should call onError when onTurnDone throws and the zone is async',
@@ -631,7 +631,7 @@ function commonTests() {
631631
expect(_errors.length).toBe(1);
632632
expect(_errors[0]).toEqual(exception);
633633
async.done();
634-
}, 50);
634+
}, 80);
635635
}));
636636
});
637637
}

modules/angular2/test/directives/ng_style_spec.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ export function main() {
2626

2727
it('should add styles specified in an object literal',
2828
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
29-
var template = `<div [ng-style]="{'text-align': 'right'}"></div>`;
29+
var template = `<div [ng-style]="{'max-width': '40px'}"></div>`;
3030

3131
tcb.overrideTemplate(TestComponent, template)
3232
.createAsync(TestComponent)
3333
.then((rootTC) => {
3434
rootTC.detectChanges();
35-
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
36-
.toEqual('right');
35+
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
36+
.toEqual('40px');
3737

3838
async.done();
3939
});
@@ -48,16 +48,16 @@ export function main() {
4848
.then((rootTC) => {
4949
var expr: Map<string, any>;
5050

51-
rootTC.componentInstance.expr = {'text-align': 'right'};
51+
rootTC.componentInstance.expr = {'max-width': '40px'};
5252
rootTC.detectChanges();
53-
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
54-
.toEqual('right');
53+
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
54+
.toEqual('40px');
5555

5656
expr = rootTC.componentInstance.expr;
57-
expr['text-align'] = 'left';
57+
expr['max-width'] = '30%';
5858
rootTC.detectChanges();
59-
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
60-
.toEqual('left');
59+
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
60+
.toEqual('30%');
6161

6262
async.done();
6363
});
@@ -70,14 +70,14 @@ export function main() {
7070
tcb.overrideTemplate(TestComponent, template)
7171
.createAsync(TestComponent)
7272
.then((rootTC) => {
73-
rootTC.componentInstance.expr = {'text-align': 'right'};
73+
rootTC.componentInstance.expr = {'max-width': '40px'};
7474
rootTC.detectChanges();
75-
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
76-
.toEqual('right');
75+
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
76+
.toEqual('40px');
7777

78-
StringMapWrapper.delete(rootTC.componentInstance.expr, 'text-align');
78+
StringMapWrapper.delete(rootTC.componentInstance.expr, 'max-width');
7979
rootTC.detectChanges();
80-
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
80+
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
8181
.toEqual('');
8282

8383
async.done();
@@ -91,16 +91,16 @@ export function main() {
9191
tcb.overrideTemplate(TestComponent, template)
9292
.createAsync(TestComponent)
9393
.then((rootTC) => {
94-
rootTC.componentInstance.expr = {'text-align': 'right'};
94+
rootTC.componentInstance.expr = {'max-width': '40px'};
9595
rootTC.detectChanges();
96-
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
97-
.toEqual('right');
96+
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
97+
.toEqual('40px');
9898
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
9999
.toEqual('12px');
100100

101-
StringMapWrapper.delete(rootTC.componentInstance.expr, 'text-align');
101+
StringMapWrapper.delete(rootTC.componentInstance.expr, 'max-width');
102102
rootTC.detectChanges();
103-
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
103+
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
104104
.toEqual('');
105105
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
106106
.toEqual('12px');
@@ -116,19 +116,19 @@ export function main() {
116116
tcb.overrideTemplate(TestComponent, template)
117117
.createAsync(TestComponent)
118118
.then((rootTC) => {
119-
rootTC.componentInstance.expr = {'text-align': 'right'};
119+
rootTC.componentInstance.expr = {'max-width': '40px'};
120120
rootTC.detectChanges();
121-
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
122-
.toEqual('right');
121+
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
122+
.toEqual('40px');
123123
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
124124
.toEqual('12px');
125125

126-
StringMapWrapper.delete(rootTC.componentInstance.expr, 'text-align');
126+
StringMapWrapper.delete(rootTC.componentInstance.expr, 'max-width');
127127
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
128128
.toEqual('12px');
129129

130130
rootTC.detectChanges();
131-
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'text-align'))
131+
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
132132
.toEqual('');
133133

134134
async.done();

modules/angular2/test/forms/integration_spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,11 @@ export function main() {
736736
rootTC.componentInstance.form = form;
737737
rootTC.detectChanges();
738738

739+
// In IE, the element needs to be appended to the real DOM,
740+
// otherwise setting .selectionStart fails with "unspecified error"
741+
var isIE = DOM.getUserAgent().indexOf("Trident") > -1;
742+
if (isIE) DOM.appendChild(DOM.defaultDoc().body, rootTC.nativeElement);
743+
739744
var input = rootTC.query(By.css("input")).nativeElement;
740745
input.value = "aa";
741746
input.selectionStart = 1;
@@ -746,6 +751,7 @@ export function main() {
746751

747752
// selection start has not changed because we did not reset the value
748753
expect(input.selectionStart).toEqual(1);
754+
if (isIE) DOM.removeChild(DOM.defaultDoc().body, rootTC.nativeElement);
749755
})));
750756
});
751757
});

modules/angular2/test/render/dom/view/view_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ export function main() {
131131
});
132132

133133
it('should de-normalize style names', () => {
134-
view.setElementStyle(0, 'textAlign', 'right');
135-
expect(DOM.getStyle(el, 'text-align')).toEqual('right');
136-
view.setElementStyle(0, 'textAlign', null);
137-
expect(DOM.getStyle(el, 'text-align')).toEqual('');
134+
view.setElementStyle(0, 'maxWidth', '40px');
135+
expect(DOM.getStyle(el, 'max-width')).toEqual('40px');
136+
view.setElementStyle(0, 'maxWidth', null);
137+
expect(DOM.getStyle(el, 'max-width')).toEqual('');
138138
});
139139

140140
});

0 commit comments

Comments
 (0)