Skip to content

Commit

Permalink
feat: support IE9
Browse files Browse the repository at this point in the history
Closes #604
  • Loading branch information
marclaval authored and pkozlowski-opensource committed Aug 18, 2016
1 parent c297921 commit 5514a97
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 25 deletions.
1 change: 1 addition & 0 deletions demo/src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'core-js/shim';
import 'classlist-polyfill';
import 'reflect-metadata';
require('zone.js/dist/zone');

Expand Down
7 changes: 6 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = function(config) {
files: [
// For travis
'node_modules/core-js/client/shim.js',
'node_modules/ie-shim/index.js',
'node_modules/reflect-metadata/Reflect.js',
// paths loaded by Karma
'node_modules/systemjs/dist/system-polyfills.js',
Expand Down Expand Up @@ -38,6 +39,10 @@ module.exports = function(config) {
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
singleRun: false,
captureTimeout: 60000,
browserDisconnectTimeout: 60000,
browserDisconnectTolerance: 3,
browserNoActivityTimeout: 60000
});
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"autoprefixer": "^6.3.6",
"bootstrap": "^4.0.0-alpha.3",
"clang-format": "1.0.35",
"classlist-polyfill": "^1.0.3",
"copy-webpack-plugin": "^3.0.1",
"core-js": "^2.4.1",
"css-loader": "^0.23.1",
Expand All @@ -58,6 +59,7 @@
"gulp-util": "^3.0.6",
"html-loader": "^0.4.3",
"html-webpack-plugin": "^2.16.1",
"ie-shim": "^0.1.0",
"jasmine": "^2.3.2",
"jasmine-core": "^2.3.4",
"jasmine-node": "^1.14.5",
Expand Down
27 changes: 16 additions & 11 deletions src/buttons/radio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,22 @@ describe('ngbRadioGroup', () => {
fixture.detectChanges();
expectRadios(fixture.nativeElement, [0, 0]);

// clicking first radio
getInput(fixture.nativeElement, 0).click();
fixture.detectChanges();
expectRadios(fixture.nativeElement, [1, 0]);
expect(fixture.componentInstance.model).toBe('one');

// clicking second radio
getInput(fixture.nativeElement, 1).click();
fixture.detectChanges();
expectRadios(fixture.nativeElement, [0, 1]);
expect(fixture.componentInstance.model).toBe('two');
fixture.whenStable()
.then(() => {
// clicking first radio
getInput(fixture.nativeElement, 0).click();
fixture.detectChanges();
expectRadios(fixture.nativeElement, [1, 0]);
expect(fixture.componentInstance.model).toBe('one');
return fixture.whenStable();
})
.then(() => {
// clicking second radio
getInput(fixture.nativeElement, 1).click();
fixture.detectChanges();
expectRadios(fixture.nativeElement, [0, 1]);
expect(fixture.componentInstance.model).toBe('two');
});
});

// TODO: remove 'whenStable' once 'core/testing' is fixed
Expand Down
5 changes: 4 additions & 1 deletion src/pagination/pagination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ describe('ngb-pagination', () => {
const html = '<ngb-pagination [collectionSize]="20" [page]="1" [size]="size"></ngb-pagination>';

const fixture = createTestComponent(html);
const classList = getList(fixture.nativeElement).classList;
let classList = getList(fixture.nativeElement).classList;

// default case
expectPages(fixture.nativeElement, ['-« Previous', '+1', '2', '» Next']);
Expand All @@ -268,18 +268,21 @@ describe('ngb-pagination', () => {
// large size
fixture.componentInstance.size = 'lg';
fixture.detectChanges();
classList = getList(fixture.nativeElement).classList;
expect(classList).toContain('pagination');
expect(classList).toContain('pagination-lg');

// removing large size
fixture.componentInstance.size = '';
fixture.detectChanges();
classList = getList(fixture.nativeElement).classList;
expect(classList).toContain('pagination');
expect(classList).not.toContain('pagination-lg');

// arbitrary string
fixture.componentInstance.size = '123';
fixture.detectChanges();
classList = getList(fixture.nativeElement).classList;
expect(classList).toContain('pagination');
expect(classList).toContain('pagination-123');
});
Expand Down
4 changes: 2 additions & 2 deletions src/progressbar/progressbar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ describe('ng-progressbar', () => {
// this might fail in IE11 if attribute binding order is not respected for the <progress> element:
// <progress [value]="" [max]=""> will fail with value = 1
// <progress [max]="" [value]=""> will work with value = 10
expect(getProgressbar(fixture.nativeElement).getAttribute('value')).toBe('10');
expect(getProgressbar(fixture.nativeElement)['value']).toBe(10);

fixture.componentInstance.value = 30;
fixture.detectChanges();
expect(getBarWidth(fixture.nativeElement)).toBe('30%');
expect(getProgressbar(fixture.nativeElement).getAttribute('value')).toBe('30');
expect(getProgressbar(fixture.nativeElement)['value']).toBe(30);
});

it('accepts a max value and respond to max changes', () => {
Expand Down
18 changes: 9 additions & 9 deletions src/timepicker/timepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ const NGB_TIMEPICKER_VALUE_ACCESSOR = {
<tr *ngIf="spinners">
<td class="text-xs-center">
<button class="btn-link" (click)="changeHour(hourStep)"
[class.disabled]="disabled">
[disabled]="disabled" [class.disabled]="disabled">
<span class="chevron"></span>
</button>
</td>
<td>&nbsp;</td>
<td class="text-xs-center">
<button class="btn-link" (click)="changeMinute(minuteStep)"
[class.disabled]="disabled">
[disabled]="disabled" [class.disabled]="disabled">
<span class="chevron"></span>
</button>
</td>
<template [ngIf]="seconds">
<td>&nbsp;</td>
<td class="text-xs-center">
<button class="btn-link" (click)="changeSecond(secondStep)"
[class.disabled]="disabled">
[disabled]="disabled" [class.disabled]="disabled">
<span class="chevron"></span>
</button>
</td>
Expand All @@ -79,19 +79,19 @@ const NGB_TIMEPICKER_VALUE_ACCESSOR = {
<td>
<input type="text" class="form-control" maxlength="2" size="2" placeholder="HH"
[value]="formatHour(model?.hour)" (change)="updateHour($event.target.value)"
[readonly]="readonlyInputs">
[readonly]="readonlyInputs" [disabled]="disabled">
</td>
<td>&nbsp;:&nbsp;</td>
<td>
<input type="text" class="form-control" maxlength="2" size="2" placeholder="MM"
[value]="formatMinSec(model?.minute)" (change)="updateMinute($event.target.value)"
[readonly]="readonlyInputs">
[readonly]="readonlyInputs" [disabled]="disabled">
</td>
<template [ngIf]="seconds">
<td>&nbsp;:&nbsp;</td>
<input type="text" class="form-control" maxlength="2" size="2" placeholder="SS"
[value]="formatMinSec(model?.second)" (change)="updateSecond($event.target.value)"
[readonly]="readonlyInputs">
[readonly]="readonlyInputs" [disabled]="disabled">
</template>
<template [ngIf]="meridian">
<td>&nbsp;&nbsp;</td>
Expand All @@ -103,22 +103,22 @@ const NGB_TIMEPICKER_VALUE_ACCESSOR = {
<tr *ngIf="spinners">
<td class="text-xs-center">
<button class="btn-link" (click)="changeHour(-hourStep)"
[class.disabled]="disabled">
[disabled]="disabled" [class.disabled]="disabled">
<span class="chevron bottom"></span>
</button>
</td>
<td>&nbsp;</td>
<td class="text-xs-center">
<button class="btn-link" (click)="changeMinute(-minuteStep)"
[class.disabled]="disabled">
[disabled]="disabled" [class.disabled]="disabled">
<span class="chevron bottom"></span>
</button>
</td>
<template [ngIf]="seconds">
<td>&nbsp;</td>
<td class="text-xs-center">
<button class="btn-link" (click)="changeSecond(-secondStep)"
[class.disabled]="disabled">
[disabled]="disabled" [class.disabled]="disabled">
<span class="chevron bottom"></span>
</button>
</td>
Expand Down
4 changes: 3 additions & 1 deletion src/typeahead/typeahead.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function getNativeInput(element: HTMLElement): HTMLInputElement {
function changeInput(element: any, value: string) {
const input = getNativeInput(element);
input.value = value;
input.dispatchEvent(new Event('input'));
const evt = document.createEvent('MouseEvent');
evt.initEvent('input', true, true);
input.dispatchEvent(evt);
}

function expectInputValue(element: HTMLElement, value: string) {
Expand Down

0 comments on commit 5514a97

Please sign in to comment.