refactor(render): ts’ify render api
This commit is contained in:
@@ -183,10 +183,9 @@ class MockStepFactory extends CompileStepFactory {
|
||||
}
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
class MockStep /*implements CompileStep*/ {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
super();
|
||||
this.processClosure = process;
|
||||
}
|
||||
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {describe, beforeEach, it, xit, expect, iit, ddescribe, el} from 'angular2/test_lib';
|
||||
import {isPresent, isBlank, assertionsEnabled} from 'angular2/src/facade/lang';
|
||||
import {isPresent, isBlank, assertionsEnabled, IMPLEMENTS} from 'angular2/src/facade/lang';
|
||||
import {ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {DirectiveParser} from 'angular2/src/render/dom/compiler/directive_parser';
|
||||
@@ -225,10 +225,10 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
@IMPLEMENTS(CompileStep)
|
||||
class MockStep {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
super();
|
||||
this.processClosure = process;
|
||||
}
|
||||
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {describe, beforeEach, it, expect, iit, ddescribe, el} from 'angular2/test_lib';
|
||||
import {ListWrapper, List, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {isPresent, NumberWrapper, StringWrapper} from 'angular2/src/facade/lang';
|
||||
import {isPresent, NumberWrapper, StringWrapper, IMPLEMENTS} from 'angular2/src/facade/lang';
|
||||
|
||||
import {CompilePipeline} from 'angular2/src/render/dom/compiler/compile_pipeline';
|
||||
import {CompileElement} from 'angular2/src/render/dom/compiler/compile_element';
|
||||
@@ -182,10 +182,10 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
@IMPLEMENTS(CompileStep)
|
||||
class MockStep {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
super();
|
||||
this.processClosure = process;
|
||||
}
|
||||
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
|
||||
@@ -193,7 +193,8 @@ class MockStep extends CompileStep {
|
||||
}
|
||||
}
|
||||
|
||||
export class IgnoreChildrenStep extends CompileStep {
|
||||
@IMPLEMENTS(CompileStep)
|
||||
export class IgnoreChildrenStep {
|
||||
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
|
||||
var attributeMap = DOM.attributeMap(current.element);
|
||||
if (MapWrapper.contains(attributeMap, 'ignore-children')) {
|
||||
@@ -202,7 +203,8 @@ export class IgnoreChildrenStep extends CompileStep {
|
||||
}
|
||||
}
|
||||
|
||||
class IgnoreCurrentElementStep extends CompileStep {
|
||||
@IMPLEMENTS(CompileStep)
|
||||
class IgnoreCurrentElementStep {
|
||||
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
|
||||
var attributeMap = DOM.attributeMap(current.element);
|
||||
if (MapWrapper.contains(attributeMap, 'ignore-current')) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import {describe, beforeEach, it, expect, iit, ddescribe, el} from 'angular2/test_lib';
|
||||
import {IMPLEMENTS} from 'angular2/src/facade/lang';
|
||||
import {PropertyBindingParser} from 'angular2/src/render/dom/compiler/property_binding_parser';
|
||||
import {CompilePipeline} from 'angular2/src/render/dom/compiler/compile_pipeline';
|
||||
import {MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {CompileElement} from 'angular2/src/render/dom/compiler/compile_element';
|
||||
import {CompileStep} from 'angular2/src/render/dom/compiler/compile_step'
|
||||
import {CompileStep} from 'angular2/src/render/dom/compiler/compile_step';
|
||||
import {CompileControl} from 'angular2/src/render/dom/compiler/compile_control';
|
||||
import {Lexer, Parser} from 'angular2/change_detection';
|
||||
|
||||
@@ -164,10 +165,10 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
@IMPLEMENTS(CompileStep)
|
||||
class MockStep {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
super();
|
||||
this.processClosure = process;
|
||||
}
|
||||
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
|
||||
|
||||
+3
-4
@@ -10,13 +10,12 @@ import {RenderViewRef, ProtoViewDto, ViewDefinition, EventDispatcher, DirectiveM
|
||||
import {resolveInternalDomView} from 'angular2/src/render/dom/view/view';
|
||||
import {el, dispatchEvent} from 'angular2/test_lib';
|
||||
|
||||
export class TestView extends EventDispatcher {
|
||||
export class TestView {
|
||||
rawView:DomView;
|
||||
viewRef:RenderViewRef;
|
||||
events:List;
|
||||
|
||||
constructor(viewRef:RenderViewRef) {
|
||||
super();
|
||||
this.viewRef = viewRef;
|
||||
this.rawView = resolveInternalDomView(viewRef);
|
||||
this.events = [];
|
||||
@@ -24,11 +23,11 @@ export class TestView extends EventDispatcher {
|
||||
}
|
||||
|
||||
|
||||
class LoggingEventDispatcher extends EventDispatcher {
|
||||
@IMPLEMENTS(EventDispatcher)
|
||||
class LoggingEventDispatcher {
|
||||
log:List;
|
||||
|
||||
constructor(log:List) {
|
||||
super();
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ export function main() {
|
||||
it('should return a string when there is no import statement', inject([StyleInliner], (inliner) => {
|
||||
var css = '.main {}';
|
||||
var loadedCss = inliner.inlineImports(css, 'http://base');
|
||||
expect(loadedCss).not.toBePromise();
|
||||
expect(loadedCss).toEqual(css);
|
||||
expect(loadedCss.syncResult).toEqual(css);
|
||||
}));
|
||||
|
||||
it('should inline @import rules',
|
||||
@@ -41,9 +40,9 @@ export function main() {
|
||||
xhr.reply('http://base/one.css', '.one {}');
|
||||
var css = '@import url("one.css");.main {}';
|
||||
var loadedCss = inliner.inlineImports(css, 'http://base');
|
||||
expect(loadedCss).toBePromise();
|
||||
expect(loadedCss.asyncResult).toBePromise();
|
||||
PromiseWrapper.then(
|
||||
loadedCss,
|
||||
loadedCss.asyncResult,
|
||||
function(css) {
|
||||
expect(css).toEqual('.one {}\n.main {}');
|
||||
async.done();
|
||||
@@ -59,9 +58,9 @@ export function main() {
|
||||
xhr.reply('http://base/one.css', '.one {}');
|
||||
var css = '@import url(one.css);.main {}';
|
||||
var loadedCss = inliner.inlineImports(css, 'http://base');
|
||||
expect(loadedCss).toBePromise();
|
||||
expect(loadedCss.asyncResult).toBePromise();
|
||||
PromiseWrapper.then(
|
||||
loadedCss,
|
||||
loadedCss.asyncResult,
|
||||
function(css) {
|
||||
expect(css).toEqual('.one {}\n.main {}');
|
||||
async.done();
|
||||
@@ -76,9 +75,9 @@ export function main() {
|
||||
inject([StyleInliner, AsyncTestCompleter], (inliner, async) => {
|
||||
var css = '@import "one.css";.main {}';
|
||||
var loadedCss = inliner.inlineImports(css, 'http://base');
|
||||
expect(loadedCss).toBePromise();
|
||||
expect(loadedCss.asyncResult).toBePromise();
|
||||
PromiseWrapper.then(
|
||||
loadedCss,
|
||||
loadedCss.asyncResult,
|
||||
function(css) {
|
||||
expect(css).toEqual('/* failed to import http://base/one.css */\n.main {}');
|
||||
async.done();
|
||||
@@ -95,9 +94,9 @@ export function main() {
|
||||
xhr.reply('http://base/two.css', '.two {}');
|
||||
var css = '@import "one.css";@import "two.css";.main {}';
|
||||
var loadedCss = inliner.inlineImports(css, 'http://base');
|
||||
expect(loadedCss).toBePromise();
|
||||
expect(loadedCss.asyncResult).toBePromise();
|
||||
PromiseWrapper.then(
|
||||
loadedCss,
|
||||
loadedCss.asyncResult,
|
||||
function(css) {
|
||||
expect(css).toEqual('.one {}\n.two {}\n.main {}');
|
||||
async.done();
|
||||
@@ -114,9 +113,9 @@ export function main() {
|
||||
xhr.reply('http://base/two.css', '.two {}');
|
||||
var css = '@import "one.css";.main {}';
|
||||
var loadedCss = inliner.inlineImports(css, 'http://base/');
|
||||
expect(loadedCss).toBePromise();
|
||||
expect(loadedCss.asyncResult).toBePromise();
|
||||
PromiseWrapper.then(
|
||||
loadedCss,
|
||||
loadedCss.asyncResult,
|
||||
function(css) {
|
||||
expect(css).toEqual('.two {}\n.one {}\n.main {}');
|
||||
async.done();
|
||||
@@ -133,9 +132,9 @@ export function main() {
|
||||
xhr.reply('http://base/two.css', '@import "one.css";.two {}');
|
||||
var css = '@import "one.css";.main {}';
|
||||
var loadedCss = inliner.inlineImports(css, 'http://base/');
|
||||
expect(loadedCss).toBePromise();
|
||||
expect(loadedCss.asyncResult).toBePromise();
|
||||
PromiseWrapper.then(
|
||||
loadedCss,
|
||||
loadedCss.asyncResult,
|
||||
function(css) {
|
||||
expect(css).toEqual('.two {}\n.one {}\n.main {}');
|
||||
async.done();
|
||||
@@ -151,9 +150,9 @@ export function main() {
|
||||
// Invalid rule: the url is not quoted
|
||||
var css = '@import one.css;.main {}';
|
||||
var loadedCss = inliner.inlineImports(css, 'http://base/');
|
||||
expect(loadedCss).toBePromise();
|
||||
expect(loadedCss.asyncResult).toBePromise();
|
||||
PromiseWrapper.then(
|
||||
loadedCss,
|
||||
loadedCss.asyncResult,
|
||||
function(css) {
|
||||
expect(css).toEqual('/* Invalid import rule: "@import one.css;" */.main {}');
|
||||
async.done();
|
||||
@@ -171,9 +170,9 @@ export function main() {
|
||||
xhr.reply('http://base/one.css', '.one {}');
|
||||
var css = '@import "one.css" (min-width: 700px) and (orientation: landscape);';
|
||||
var loadedCss = inliner.inlineImports(css, 'http://base/');
|
||||
expect(loadedCss).toBePromise();
|
||||
expect(loadedCss.asyncResult).toBePromise();
|
||||
PromiseWrapper.then(
|
||||
loadedCss,
|
||||
loadedCss.asyncResult,
|
||||
function(css) {
|
||||
expect(css).toEqual('@media (min-width: 700px) and (orientation: landscape) {\n.one {}\n}\n');
|
||||
async.done();
|
||||
@@ -193,9 +192,9 @@ export function main() {
|
||||
xhr.reply('http://base/nested/two.css', '.two {background-image: url("../img/two.jpg");}');
|
||||
var css = '@import "one.css";'
|
||||
var loadedCss = inliner.inlineImports(css, 'http://base/');
|
||||
expect(loadedCss).toBePromise();
|
||||
expect(loadedCss.asyncResult).toBePromise();
|
||||
PromiseWrapper.then(
|
||||
loadedCss,
|
||||
loadedCss.asyncResult,
|
||||
function(css) {
|
||||
expect(css).toEqual(
|
||||
".two {background-image: url('http://base/img/two.jpg');}\n" +
|
||||
|
||||
Reference in New Issue
Block a user