fix: make all tests green with new view engine and JIT

Note that this does not yet include enabling the view engine
by default.

Included refactoring:
- view engine: split namespace of elements / attributes already
  when creating the `NodeDef`
- view engine: when injecting the old `Renderer`, use an implementation
  that is based on `RendererV2`
- view engine: store view queries in the component view, not
  on the host element
This commit is contained in:
Tobias Bosch
2017-02-17 08:56:36 -08:00
committed by Igor Minar
parent 74ce121dba
commit b9f17a9cb2
37 changed files with 527 additions and 300 deletions

View File

@ -17,16 +17,6 @@ export class ChangeDetectionPerfRecord {
constructor(public msPerTick: number, public numTicks: number) {}
}
/**
* Entry point for all Angular debug tools. This object corresponds to the `ng`
* global variable accessible in the dev console.
*/
export class AngularTools {
profiler: AngularProfiler;
constructor(ref: ComponentRef<any>) { this.profiler = new AngularProfiler(ref); }
}
/**
* Entry point for all Angular profiling-related debug tools. This object
* corresponds to the `ng.profiler` in the dev console.

View File

@ -7,11 +7,11 @@
*/
import {ComponentRef} from '@angular/core';
import {global} from '../../facade/lang';
import {getDOM} from '../../dom/dom_adapter';
import {AngularTools} from './common_tools';
import {AngularProfiler} from './common_tools';
const context = <any>global;
const PROFILER_GLOBAL_NAME = 'ng.profiler';
/**
* Enabled Angular debug tools that are accessible via your browser's
@ -27,7 +27,7 @@ const context = <any>global;
* @experimental All debugging apis are currently experimental.
*/
export function enableDebugTools<T>(ref: ComponentRef<T>): ComponentRef<T> {
(<any>Object).assign(context.ng, new AngularTools(ref));
getDOM().setGlobalVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
return ref;
}
@ -37,7 +37,5 @@ export function enableDebugTools<T>(ref: ComponentRef<T>): ComponentRef<T> {
* @experimental All debugging apis are currently experimental.
*/
export function disableDebugTools(): void {
if (context.ng) {
delete context.ng.profiler;
}
getDOM().setGlobalVar(PROFILER_GLOBAL_NAME, null);
}

View File

@ -434,6 +434,9 @@ class DefaultDomRendererV2 implements RendererV2 {
selectRootElement(selectorOrNode: string|any): any {
let el: any = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) :
selectorOrNode;
if (!el) {
throw new Error(`The selector "${selectorOrNode}" did not match any elements`);
}
el.textContent = '';
return el;
}
@ -464,13 +467,21 @@ class DefaultDomRendererV2 implements RendererV2 {
setStyle(el: any, style: string, value: any, hasVendorPrefix: boolean, hasImportant: boolean):
void {
el.style[style] = value;
if (hasVendorPrefix || hasImportant) {
el.style.setProperty(style, value, hasImportant ? 'important' : '');
} else {
el.style[style] = value;
}
}
removeStyle(el: any, style: string, hasVendorPrefix: boolean): void {
// IE requires '' instead of null
// see https://github.com/angular/angular/issues/7916
el.style[style] = '';
if (hasVendorPrefix) {
el.style.removeProperty(style);
} else {
// IE requires '' instead of null
// see https://github.com/angular/angular/issues/7916
el.style[style] = '';
}
}
setProperty(el: any, name: string, value: any): void { el[name] = value; }