chore(angular): update angular tests to ng v6 and latest stencil

This commit is contained in:
Adam Bradley
2018-05-16 11:40:28 -05:00
parent f3dc8a0fed
commit 3bb661fa11
182 changed files with 9755 additions and 5936 deletions

View File

@ -0,0 +1,42 @@
import { Config } from './providers/config';
import { defineCustomElements } from '@ionic/core';
import { IonicWindow } from './types/interfaces';
export function appInitialize(config: Config) {
return () => {
const win: IonicWindow = window as any;
if (typeof win !== 'undefined') {
const Ionic = win.Ionic = win.Ionic || {};
Ionic.config = config;
Ionic.ael = (elm, eventName, cb, opts) => {
if (elm.__zone_symbol__addEventListener) {
elm.__zone_symbol__addEventListener(eventName, cb, opts);
} else {
elm.addEventListener(eventName, cb, opts);
}
};
Ionic.rel = (elm, eventName, cb, opts) => {
if (elm.__zone_symbol__removeEventListener) {
elm.__zone_symbol__removeEventListener(eventName, cb, opts);
} else {
elm.removeEventListener(eventName, cb, opts);
}
};
Ionic.raf = (cb: any) => {
if (win.__zone_symbol__requestAnimationFrame) {
win.__zone_symbol__requestAnimationFrame(cb);
} else {
win.requestAnimationFrame(cb);
}
};
// define all of Ionic's custom elements
defineCustomElements(win);
}
};
}

View File

@ -26,6 +26,7 @@ export const DIRECTIVES = [
d.Grid,
d.Header,
d.HideWhen,
d.Img,
d.InfiniteScroll,
d.InfiniteScrollContent,
d.Input,

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,22 @@
import { ChangeDetectorRef, ContentChild, Directive, ElementRef, EmbeddedViewRef } from '@angular/core';
import { proxyInputs } from '../proxies';
import { VirtualItem } from './virtual-item';
import { VirtualHeader } from './virtual-header';
import { VirtualFooter } from './virtual-footer';
import { VirtualContext } from './virtual-utils';
@Directive({
selector: 'ion-virtual-scroll'
selector: 'ion-virtual-scroll',
inputs: [
'approxItemHeight',
'approxHeaderHeight',
'approxFooterHeight',
'headerFn',
'footerFn',
'items',
'itemHeight'
]
})
export class VirtualScroll {
@ -17,7 +28,17 @@ export class VirtualScroll {
private el: ElementRef,
public cd: ChangeDetectorRef,
) {
this.el.nativeElement.nodeRender = this.nodeRender.bind(this);
el.nativeElement.nodeRender = this.nodeRender.bind(this);
proxyInputs(this, this.el, [
'approxItemHeight',
'approxHeaderHeight',
'approxFooterHeight',
'headerFn',
'footerFn',
'items',
'itemHeight'
]);
}
private nodeRender(el: HTMLElement|null, cell: any, index?: number) {

View File

@ -1,5 +1,5 @@
// export module
export { IonicModule } from './module';
export { IonicModule } from './ionic-module';
// export auto generated directive
export * from './directives/proxies';
@ -15,6 +15,3 @@ export * from './types/interfaces';
// ionic oute reuse strategy
export * from './util/ionic-router-reuse-strategy';
/*tslint:disable*/
import './ionic-angular';

View File

@ -1,32 +0,0 @@
/*tslint:disable*/
import './ionic';
import { IonicWindow } from './types/interfaces';
const win = (window as IonicWindow);
const Ionic = win.Ionic;
if (Ionic) {
Ionic.ael = function ngAddEventListener(elm, eventName, cb, opts) {
if (elm.__zone_symbol__addEventListener) {
elm.__zone_symbol__addEventListener(eventName, cb, opts);
} else {
elm.addEventListener(eventName, cb, opts);
}
};
Ionic.rel = function ngRemoveEventListener(elm, eventName, cb, opts) {
if (elm.__zone_symbol__removeEventListener) {
elm.__zone_symbol__removeEventListener(eventName, cb, opts);
} else {
elm.removeEventListener(eventName, cb, opts);
}
};
Ionic.raf = function ngRequestAnimationFrame(cb: any) {
if (win.__zone_symbol__requestAnimationFrame) {
win.__zone_symbol__requestAnimationFrame(cb);
} else {
win.requestAnimationFrame(cb);
}
};
}

View File

@ -1,10 +1,13 @@
import { ModuleWithProviders, NgModule } from '@angular/core';
import { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { appInitialize } from './app-initialize';
import { ConfigToken } from './providers/config';
import * as c from './directives';
import * as d from './directives/proxies';
import * as p from './providers';
const DECLARATIONS = [
// proxies
d.App,
@ -31,6 +34,7 @@ const DECLARATIONS = [
d.Grid,
d.Header,
d.HideWhen,
d.Img,
d.InfiniteScroll,
d.InfiniteScrollContent,
d.Input,
@ -111,6 +115,7 @@ const DECLARATIONS = [
const PROVIDERS = [
p.ActionSheetController,
p.AlertController,
p.Config,
p.LoadingController,
p.PickerController,
p.ToastController,
@ -121,6 +126,7 @@ const PROVIDERS = [
p.DomController
];
@NgModule({
declarations: DECLARATIONS,
exports: DECLARATIONS,
@ -128,11 +134,23 @@ const PROVIDERS = [
imports: [CommonModule]
})
export class IonicModule {
static forRoot(_config?: { [key: string]: any }): ModuleWithProviders {
static forRoot(config?: { [key: string]: any }): ModuleWithProviders {
return {
ngModule: IonicModule,
providers: [
...PROVIDERS,
{
provide: ConfigToken,
useValue: config
},
{
provide: APP_INITIALIZER,
useFactory: appInitialize,
multi: true,
deps: [
ConfigToken
]
},
...PROVIDERS
]
};
}

View File

@ -1,3 +0,0 @@
// placeholder for ionic loader js
// created by the stencil build process

View File

@ -1,31 +1,51 @@
import { Config as CoreConfig } from '@ionic/core';
import { InjectionToken } from '@angular/core';
import { IonicWindow } from '../types/interfaces';
export class Config {
get(key: string, fallback?: any): any {
return getConfig().get(key, fallback);
const c = getConfig();
if (c) {
return c.get(key, fallback);
}
return null;
}
getBoolean(key: string, fallback?: boolean): boolean {
return getConfig().getBoolean(key, fallback);
const c = getConfig();
if (c) {
return c.getBoolean(key, fallback);
}
return null;
}
getNumber(key: string, fallback?: number): number {
return getConfig().getNumber(key, fallback);
const c = getConfig();
if (c) {
return c.getNumber(key, fallback);
}
return null;
}
set(key: string, value?: any) {
getConfig().set(key, value);
const c = getConfig();
if (c) {
c.set(key, value);
}
}
}
export const ConfigToken = new InjectionToken<any>('USERCONFIG');
function getConfig(): CoreConfig {
const Ionic = (window as any).Ionic;
if (Ionic && Ionic.config) {
return Ionic.config;
const win: IonicWindow = window as any;
if (typeof win !== 'undefined') {
const Ionic = win.Ionic;
if (Ionic && Ionic.config) {
return Ionic.config;
}
}
return null;
}

View File

@ -1,7 +1,7 @@
import { EventEmitter, Injectable } from '@angular/core';
import { proxyEvent } from '../util/util';
import { PlatformConfig, detectPlatforms } from '@ionic/core';
import { proxyEvent } from '../util/util';
@Injectable()
export class Platform {
@ -37,7 +37,6 @@ export class Platform {
resize = new EventEmitter<Event>();
constructor() {
proxyEvent(this.pause, document, 'pause');
proxyEvent(this.resume, document, 'resume');
proxyEvent(this.backButton, document, 'backbutton');

View File

@ -1,9 +1,9 @@
export interface IonicGlobal {
config: any;
ael: (elm: any, eventName: string, cb: Function, opts: any) => void;
raf: Function;
rel: (elm: any, eventName: string, cb: Function, opts: any) => void;
config?: any;
ael?: (elm: any, eventName: string, cb: Function, opts: any) => void;
raf?: Function;
rel?: (elm: any, eventName: string, cb: Function, opts: any) => void;
}
export interface IonicWindow extends Window {