Skip to content

fix: update angular to beta.17 #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
"node": ">= 4.2.1 < 5"
},
"dependencies": {
"angular2": "2.0.0-beta.15",
"angular2": "2.0.0-beta.17",
"es6-promise": "^3.0.2",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"rxjs": "5.0.0-beta.6",
"systemjs": "0.19.20",
"zone.js": "0.6.10"
"zone.js": "0.6.12"
},
"devDependencies": {
"add-stream": "^1.0.0",
Expand Down
26 changes: 10 additions & 16 deletions src/components/button/button.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import {
it,
describe,
expect,
beforeEach,
inject,
TestComponentBuilder
} from 'angular2/testing';
import {it, describe, expect, beforeEach, inject, TestComponentBuilder} from 'angular2/testing';
import {Component} from 'angular2/core';
import {By} from 'angular2/platform/browser';

import {MdButton, MdAnchor} from './button';



export function main() {
describe('MdButton', () => {
let builder: TestComponentBuilder;
Expand All @@ -21,7 +15,7 @@ export function main() {

// General button tests
it('should apply class based on color attribute', (done: () => void) => {
return builder.createAsync(TestApp).then((fixture) => {
return builder.createAsync(TestApp).then(fixture => {
let testComponent = fixture.debugElement.componentInstance;
let buttonDebugElement = fixture.debugElement.query(By.css('button'));
let aDebugElement = fixture.debugElement.query(By.css('a'));
Expand All @@ -40,7 +34,7 @@ export function main() {
});

it('should should not clear previous defined classes', (done: () => void) => {
return builder.createAsync(TestApp).then((fixture) => {
return builder.createAsync(TestApp).then(fixture => {
let testComponent = fixture.debugElement.componentInstance;
let buttonDebugElement = fixture.debugElement.query(By.css('button'));

Expand All @@ -66,7 +60,7 @@ export function main() {
// Regular button tests
describe('button[md-button]', () => {
it('should handle a click on the button', (done: () => void) => {
return builder.createAsync(TestApp).then((fixture) => {
return builder.createAsync(TestApp).then(fixture => {
let testComponent = fixture.debugElement.componentInstance;
let buttonDebugElement = fixture.debugElement.query(By.css('button'));

Expand All @@ -77,7 +71,7 @@ export function main() {
});

it('should not increment if disabled', (done: () => void) => {
return builder.createAsync(TestApp).then((fixture) => {
return builder.createAsync(TestApp).then(fixture => {
let testComponent = fixture.debugElement.componentInstance;
let buttonDebugElement = fixture.debugElement.query(By.css('button'));

Expand All @@ -96,7 +90,7 @@ export function main() {
// Anchor button tests
describe('a[md-button]', () => {
it('should not redirect if disabled', (done: () => void) => {
return builder.createAsync(TestApp).then((fixture) => {
return builder.createAsync(TestApp).then(fixture => {
let testComponent = fixture.debugElement.componentInstance;
let buttonDebugElement = fixture.debugElement.query(By.css('a'));

Expand All @@ -110,7 +104,7 @@ export function main() {
});

it('should remove tabindex if disabled', (done: () => void) => {
return builder.createAsync(TestApp).then((fixture) => {
return builder.createAsync(TestApp).then(fixture => {
let testComponent = fixture.debugElement.componentInstance;
let buttonDebugElement = fixture.debugElement.query(By.css('a'));
expect(buttonDebugElement.nativeElement.getAttribute('tabIndex')).toBe(null);
Expand All @@ -123,7 +117,7 @@ export function main() {
});

it('should add aria-disabled attribute if disabled', (done: () => void) => {
return builder.createAsync(TestApp).then((fixture) => {
return builder.createAsync(TestApp).then(fixture => {
let testComponent = fixture.debugElement.componentInstance;
let buttonDebugElement = fixture.debugElement.query(By.css('a'));
fixture.detectChanges();
Expand Down
2 changes: 1 addition & 1 deletion src/components/checkbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A demo of the checkbox can be found at https://plnkr.co/edit/P7qce8lN9n2flS6kBhD

```html
<ul>
<li *ngFor="#todo of todos">
<li *ngFor="let todo of todos">
<md-checkbox [checked]="todo.completed"
(change)="todo.completed = $event">
{{todo.name}}
Expand Down
2 changes: 1 addition & 1 deletion src/components/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class MdCheckbox implements ControlValueAccessor {
@Input() tabindex: number = 0;

/** Event emitted when the checkbox's `checked` value changes. */
@Output() change: EventEmitter<boolean> = new EventEmitter();
@Output() change: EventEmitter<boolean> = new EventEmitter<boolean>();

/** Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor. */
onTouched: () => any = () => {};
Expand Down
23 changes: 16 additions & 7 deletions src/components/icon/icon-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ export class MdIconRegistry {
*/
getSvgIconFromUrl(url: string): Observable<SVGElement> {
if (this._cachedIconsByUrl.has(url)) {
return Observable.of(this._cachedIconsByUrl.get(url).cloneNode(true));
return Observable.of(cloneSvg(this._cachedIconsByUrl.get(url)));
}
return this._loadSvgIconFromConfig(new SvgIconConfig(url))
.do(svg => this._cachedIconsByUrl.set(url, svg))
.map(svg => svg.cloneNode(true));
.map(svg => cloneSvg(svg));
}

/**
Expand Down Expand Up @@ -175,12 +175,12 @@ export class MdIconRegistry {
private _getSvgFromConfig(config: SvgIconConfig): Observable<SVGElement> {
if (config.svgElement) {
// We already have the SVG element for this icon, return a copy.
return Observable.of(config.svgElement.cloneNode(true));
return Observable.of(cloneSvg(config.svgElement));
} else {
// Fetch the icon from the config's URL, cache it, and return a copy.
return this._loadSvgIconFromConfig(config)
.do(svg => config.svgElement = svg)
.map(svg => svg.cloneNode(true));
.map(svg => cloneSvg(svg));
}
}

Expand Down Expand Up @@ -209,7 +209,7 @@ export class MdIconRegistry {
.filter(iconSetConfig => !iconSetConfig.svgElement)
.map(iconSetConfig =>
this._loadSvgIconSetFromConfig(iconSetConfig)
.catch((err: any, source: any, caught: any): Observable<SVGElement> => {
.catch((err: any, caught: Observable<SVGElement>): Observable<SVGElement> => {
// Swallow errors fetching individual URLs so the combined Observable won't
// necessarily fail.
console.log(`Loading icon set URL: ${iconSetConfig.url} failed: ${err}`);
Expand Down Expand Up @@ -349,8 +349,11 @@ export class MdIconRegistry {
if (this._inProgressUrlFetches.has(url)) {
return this._inProgressUrlFetches.get(url);
}
const req = this._http.get(url)
.map((response) => response.text())

// TODO(jelbourn): for some reason, the `finally` operator "loses" the generic type on the
// Observable. Figure out why and fix it.
const req = <Observable<string>> this._http.get(url)
.map(response => response.text())
.finally(() => {
this._inProgressUrlFetches.delete(url);
})
Expand All @@ -359,3 +362,9 @@ export class MdIconRegistry {
return req;
}
}


/** Clones an SVGElement while preserving type information. */
function cloneSvg(svg: SVGElement) {
return <SVGElement> svg.cloneNode(true);
}
55 changes: 27 additions & 28 deletions src/components/icon/icon.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import {
it,
describe,
expect,
beforeEach,
beforeEachProviders,
inject,
TestComponentBuilder,
it,
describe,
expect,
beforeEach,
beforeEachProviders,
inject,
TestComponentBuilder
} from 'angular2/testing';
import {
HTTP_PROVIDERS,
XHRBackend} from 'angular2/http';
import {HTTP_PROVIDERS, XHRBackend} from 'angular2/http';
import {MockBackend} from 'angular2/http/testing';
import {
provide,
Component} from 'angular2/core';

import {provide, Component} from 'angular2/core';
import {MdIcon} from './icon';
import {MdIconRegistry} from './icon-registry';
import {getFakeSvgHttpResponse} from './fake-svgs';



/** Returns the CSS classes assigned to an element as a sorted array. */
const sortedClassNames = (elem: Element) => elem.className.split(' ').sort();

Expand Down Expand Up @@ -74,7 +71,7 @@ export function main() {

describe('Ligature icons', () => {
it('should add material-icons class by default', (done: () => void) => {
return builder.createAsync(MdIconLigatureTestApp).then((fixture) => {
return builder.createAsync(MdIconLigatureTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
testComponent.iconName = 'home';
Expand All @@ -86,7 +83,7 @@ export function main() {

it('should use alternate icon font if set', (done: () => void) => {
mdIconRegistry.setDefaultFontSetClass('myfont');
return builder.createAsync(MdIconLigatureTestApp).then((fixture) => {
return builder.createAsync(MdIconLigatureTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
testComponent.iconName = 'home';
Expand All @@ -99,7 +96,7 @@ export function main() {

describe('Icons from URLs', () => {
it('should fetch SVG icon from URL and inline the content', (done: () => void) => {
return builder.createAsync(MdIconFromSvgUrlTestApp).then((fixture) => {
return builder.createAsync(MdIconFromSvgUrlTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
let svgElement: any;
Expand Down Expand Up @@ -135,7 +132,7 @@ export function main() {
it('should register icon URLs by name', (done: () => void) => {
mdIconRegistry.addSvgIcon('fluffy', 'cat.svg');
mdIconRegistry.addSvgIcon('fido', 'dog.svg');
return builder.createAsync(MdIconFromSvgNameTestApp).then((fixture) => {
return builder.createAsync(MdIconFromSvgNameTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
let svgElement: SVGElement;
Expand Down Expand Up @@ -168,7 +165,7 @@ export function main() {

it('should extract icon from SVG icon set', (done: () => void) => {
mdIconRegistry.addSvgIconSetInNamespace('farm', 'farm-set-1.svg');
return builder.createAsync(MdIconFromSvgNameTestApp).then((fixture) => {
return builder.createAsync(MdIconFromSvgNameTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
let svgElement: any;
Expand Down Expand Up @@ -207,7 +204,7 @@ export function main() {
mdIconRegistry.addSvgIconSetInNamespace('farm', 'farm-set-1.svg');
mdIconRegistry.addSvgIconSetInNamespace('farm', 'farm-set-2.svg');
mdIconRegistry.addSvgIconSetInNamespace('arrows', 'arrow-set.svg');
return builder.createAsync(MdIconFromSvgNameTestApp).then((fixture) => {
return builder.createAsync(MdIconFromSvgNameTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
let svgElement: any;
Expand Down Expand Up @@ -250,7 +247,7 @@ export function main() {

it('should not wrap <svg> elements in icon sets in another svg tag', (done: () => void) => {
mdIconRegistry.addSvgIconSet('arrow-set.svg');
return builder.createAsync(MdIconFromSvgNameTestApp).then((fixture) => {
return builder.createAsync(MdIconFromSvgNameTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
let svgElement: any;
Expand All @@ -268,7 +265,7 @@ export function main() {
});

it('should return unmodified copies of icons from URLs', (done: () => void) => {
return builder.createAsync(MdIconFromSvgUrlTestApp).then((fixture) => {
return builder.createAsync(MdIconFromSvgUrlTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
let svgElement: any;
Expand Down Expand Up @@ -299,7 +296,7 @@ export function main() {

it('should return unmodified copies of icons from icon sets', (done: () => void) => {
mdIconRegistry.addSvgIconSet('arrow-set.svg');
return builder.createAsync(MdIconFromSvgNameTestApp).then((fixture) => {
return builder.createAsync(MdIconFromSvgNameTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
let svgElement: any;
Expand Down Expand Up @@ -333,7 +330,7 @@ export function main() {
it('should apply CSS classes for custom font and icon', (done: () => void) => {
mdIconRegistry.registerFontClassAlias('f1', 'font1');
mdIconRegistry.registerFontClassAlias('f2');
return builder.createAsync(MdIconCustomFontCssTestApp).then((fixture) => {
return builder.createAsync(MdIconCustomFontCssTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
testComponent.fontSet = 'f1';
Expand Down Expand Up @@ -361,10 +358,12 @@ export function main() {

describe('aria label', () => {
it('should set aria label from text content if not specified', (done: () => void) => {
return builder.createAsync(MdIconLigatureTestApp).then((fixture) => {
return builder.createAsync(MdIconLigatureTestApp).then(fixture => {

const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
testComponent.iconName = 'home';

fixture.detectChanges();
expect(mdIconElement.getAttribute('aria-label')).toBe('home');

Expand All @@ -377,7 +376,7 @@ export function main() {
});

it('should use alt tag if aria label is not specified', (done: () => void) => {
return builder.createAsync(MdIconLigatureWithAriaBindingTestApp).then((fixture) => {
return builder.createAsync(MdIconLigatureWithAriaBindingTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
testComponent.iconName = 'home';
Expand All @@ -394,7 +393,7 @@ export function main() {
});

it('should use provided aria label rather than icon name', (done: () => void) => {
return builder.createAsync(MdIconLigatureWithAriaBindingTestApp).then((fixture) => {
return builder.createAsync(MdIconLigatureWithAriaBindingTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
testComponent.iconName = 'home';
Expand All @@ -406,7 +405,7 @@ export function main() {
});

it('should use provided aria label rather than font icon', (done: () => void) => {
return builder.createAsync(MdIconCustomFontCssTestApp).then((fixture) => {
return builder.createAsync(MdIconCustomFontCssTestApp).then(fixture => {
const testComponent = fixture.debugElement.componentInstance;
const mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
testComponent.fontSet = 'f1';
Expand Down
Loading