feat(compiler): DOM adapters + html5lib implementation; misc fixes
This commit is contained in:
@@ -11,7 +11,6 @@ import {ChangeDispatcher, DynamicChangeDetector, ChangeDetectionError, ContextWi
|
||||
|
||||
import {ChangeDetectionUtil} from 'angular2/src/change_detection/change_detection_util';
|
||||
|
||||
|
||||
import {JitProtoChangeDetector, DynamicProtoChangeDetector} from 'angular2/src/change_detection/proto_change_detector';
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ function expectKeywordToken(token, index, keyword) {
|
||||
expect(token.toString()).toEqual(keyword);
|
||||
}
|
||||
|
||||
|
||||
export function main() {
|
||||
describe('lexer', function() {
|
||||
describe('token', function() {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import {describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach} from '
|
||||
import {bootstrap, appDocumentToken, appElementToken}
|
||||
from 'angular2/src/core/application';
|
||||
import {Component} from 'angular2/src/core/annotations/annotations';
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {bind, Inject} from 'angular2/di';
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Runs compiler tests using in-browser DOM adapter.
|
||||
*/
|
||||
|
||||
import {runCompilerCommonTests} from './compiler_common_tests';
|
||||
|
||||
export function main() {
|
||||
runCompilerCommonTests();
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import {describe, beforeEach, it, expect, ddescribe, iit, el, IS_DARTIUM} from 'angular2/test_lib';
|
||||
|
||||
import {DOM, Element, TemplateElement} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {List, ListWrapper, Map, MapWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {Type, isBlank, stringify, isPresent} from 'angular2/src/facade/lang';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
@@ -22,7 +22,7 @@ import {StyleUrlResolver} from 'angular2/src/core/compiler/style_url_resolver';
|
||||
import {Lexer, Parser, dynamicChangeDetection} from 'angular2/change_detection';
|
||||
import {ShadowDomStrategy, NativeShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy';
|
||||
|
||||
export function main() {
|
||||
export function runCompilerCommonTests() {
|
||||
describe('compiler', function() {
|
||||
StringMapWrapper.forEach({
|
||||
'(sync TemplateLoader)': true,
|
||||
@@ -0,0 +1,9 @@
|
||||
library angular2.compiler.html5lib_dom_adapter.test;
|
||||
|
||||
import 'package:angular2/src/dom/html5lib_adapter.dart';
|
||||
import 'compiler_common_tests.dart';
|
||||
|
||||
void main() {
|
||||
Html5LibDomAdapter.makeCurrent();
|
||||
runCompilerCommonTests();
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular2/test_lib';
|
||||
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {Type, isPresent, BaseException} from 'angular2/src/facade/lang';
|
||||
import {assertionsEnabled, isJsObject} from 'angular2/src/facade/lang';
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import {describe, beforeEach, it, expect, iit, ddescribe, el} from 'angular2/test_lib';
|
||||
import {isPresent, normalizeBlank} from 'angular2/src/facade/lang';
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {ElementBinderBuilder} from 'angular2/src/core/compiler/pipeline/element_binder_builder';
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import {describe, beforeEach, it, expect, iit, ddescribe, el} from 'angular2/test_lib';
|
||||
import {isPresent} from 'angular2/src/facade/lang';
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {MapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {ElementBindingMarker} from 'angular2/src/core/compiler/pipeline/element_binding_marker';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {isPresent, NumberWrapper, StringWrapper} from 'angular2/src/facade/lang';
|
||||
|
||||
import {CompilePipeline} from 'angular2/src/core/compiler/pipeline/compile_pipeline';
|
||||
|
||||
+7
-5
@@ -15,16 +15,18 @@ import {ProtoElementInjector} from 'angular2/src/core/compiler/element_injector'
|
||||
export function main() {
|
||||
describe('ProtoElementInjectorBuilder', () => {
|
||||
var protoElementInjectorBuilder, protoView;
|
||||
// Create consts for an elements with a var- so that we can fake parsing the var into
|
||||
// the CompileElement's variableBindings without actually doing any parsing.
|
||||
var ELEMENT_WITH_VAR;
|
||||
var DIRECTIVE_ELEMENT_WITH_VAR;
|
||||
|
||||
beforeEach( () => {
|
||||
ELEMENT_WITH_VAR = el('<div var-name></div>');
|
||||
DIRECTIVE_ELEMENT_WITH_VAR = el('<div var-name directives></div>');
|
||||
protoElementInjectorBuilder = new TestableProtoElementInjectorBuilder();
|
||||
protoView = new ProtoView(null, null, null);
|
||||
});
|
||||
|
||||
// Create consts for an elements with a var- so that we can fake parsing the var into
|
||||
// the CompileElement's variableBindings without actually doing any parsing.
|
||||
var ELEMENT_WITH_VAR = el('<div var-name></div>');
|
||||
var DIRECTIVE_ELEMENT_WITH_VAR = el('<div var-name directives></div>');
|
||||
|
||||
function createPipeline(directives = null) {
|
||||
if (isBlank(directives)) {
|
||||
directives = [];
|
||||
|
||||
@@ -22,7 +22,7 @@ import {ShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy'
|
||||
import {ProtoView} from 'angular2/src/core/compiler/view';
|
||||
|
||||
import {IMPLEMENTS, Type, stringify} from 'angular2/src/facade/lang';
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
export function main() {
|
||||
|
||||
@@ -11,7 +11,7 @@ import {DirectiveMetadata} from 'angular2/src/core/compiler/directive_metadata';
|
||||
import {ShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy';
|
||||
|
||||
import {Type, isBlank, stringify} from 'angular2/src/facade/lang';
|
||||
import {DOM, Element} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
export function main() {
|
||||
describe('ShimShadowDom', () => {
|
||||
@@ -62,12 +62,12 @@ class FakeStrategy extends ShadowDomStrategy {
|
||||
super();
|
||||
}
|
||||
|
||||
shimContentElement(component: Type, element: Element) {
|
||||
shimContentElement(component: Type, element) {
|
||||
var attrName = stringify(component) + '-content';
|
||||
DOM.setAttribute(element, attrName, '');
|
||||
}
|
||||
|
||||
shimHostElement(component: Type, element: Element) {
|
||||
shimHostElement(component: Type, element) {
|
||||
var attrName = stringify(component) + '-host';
|
||||
DOM.setAttribute(element, attrName, '');
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import {MapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {ViewSplitter} from 'angular2/src/core/compiler/pipeline/view_splitter';
|
||||
import {CompilePipeline} from 'angular2/src/core/compiler/pipeline/compile_pipeline';
|
||||
import {DOM, TemplateElement} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {Lexer, Parser} from 'angular2/change_detection';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {describe, beforeEach, it, expect, ddescribe, iit, SpyObject, el, proxy} from 'angular2/test_lib';
|
||||
import {IMPLEMENTS} from 'angular2/src/facade/lang';
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {Content} from 'angular2/src/core/compiler/shadow_dom_emulation/content_tag';
|
||||
import {NgElement} from 'angular2/src/core/dom/element';
|
||||
import {LightDom} from 'angular2/src/core/compiler/shadow_dom_emulation/light_dom';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {describe, beforeEach, it, expect, ddescribe, iit, SpyObject, el, proxy} from 'angular2/test_lib';
|
||||
import {IMPLEMENTS, isBlank} from 'angular2/src/facade/lang';
|
||||
import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {Content} from 'angular2/src/core/compiler/shadow_dom_emulation/content_tag';
|
||||
import {LightDom} from 'angular2/src/core/compiler/shadow_dom_emulation/light_dom';
|
||||
import {View} from 'angular2/src/core/compiler/view';
|
||||
|
||||
+4
-1
@@ -2,7 +2,7 @@ import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular
|
||||
|
||||
import {StringMapWrapper, List} from 'angular2/src/facade/collection';
|
||||
import {Type} from 'angular2/src/facade/lang';
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {Injector} from 'angular2/di';
|
||||
import {Lexer, Parser, ChangeDetector, dynamicChangeDetection} from 'angular2/change_detection';
|
||||
@@ -29,7 +29,10 @@ import {Template} from 'angular2/src/core/annotations/template';
|
||||
|
||||
import {ViewContainer} from 'angular2/src/core/compiler/view_container';
|
||||
|
||||
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
|
||||
|
||||
export function main() {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
describe('integration tests', function() {
|
||||
var urlResolver = new UrlResolver();
|
||||
var styleUrlResolver = new StyleUrlResolver(urlResolver);
|
||||
|
||||
@@ -13,7 +13,7 @@ import {ProtoView} from 'angular2/src/core/compiler/view';
|
||||
import {XHR} from 'angular2/src/core/compiler/xhr/xhr';
|
||||
|
||||
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {Map, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {PromiseWrapper, Promise} from 'angular2/src/facade/async';
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular2/test_lib';
|
||||
|
||||
import {TemplateLoader} from 'angular2/src/core/compiler/template_loader';
|
||||
import {UrlResolver} from 'angular2/src/core/compiler/url_resolver';
|
||||
|
||||
import {Template} from 'angular2/src/core/annotations/template';
|
||||
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
import {XHRMock} from 'angular2/src/mock/xhr_mock';
|
||||
|
||||
export function main() {
|
||||
|
||||
@@ -2,7 +2,7 @@ import {describe, xit, it, expect, beforeEach, ddescribe, iit, el, proxy} from '
|
||||
import {View, ProtoView} from 'angular2/src/core/compiler/view';
|
||||
import {ViewContainer} from 'angular2/src/core/compiler/view_container';
|
||||
import {IMPLEMENTS} from 'angular2/src/facade/lang';
|
||||
import {DOM, Node} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {Injector} from 'angular2/di';
|
||||
import {ProtoElementInjector, ElementInjector} from 'angular2/src/core/compiler/element_injector';
|
||||
@@ -33,7 +33,7 @@ class AttachableChangeDetector {
|
||||
@IMPLEMENTS(View)
|
||||
class HydrateAwareFakeView {
|
||||
isHydrated: boolean;
|
||||
nodes: List<Node>;
|
||||
nodes: List;
|
||||
changeDetector: ChangeDetector;
|
||||
rootElementInjectors;
|
||||
constructor(isHydrated) {
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import {Lexer, Parser, DynamicProtoChangeDetector,
|
||||
ChangeDetector} from 'angular2/change_detection';
|
||||
import {EventEmitter} from 'angular2/src/core/annotations/events';
|
||||
import {List, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {DOM, Element} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {int, IMPLEMENTS} from 'angular2/src/facade/lang';
|
||||
import {Injector} from 'angular2/di';
|
||||
import {View} from 'angular2/src/core/compiler/view';
|
||||
|
||||
+3
-2
@@ -2,7 +2,8 @@ import {describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach, el} fr
|
||||
import {EventManager, EventManagerPlugin, DomEventsPlugin} from 'angular2/src/core/events/event_manager';
|
||||
import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone';
|
||||
import {List, ListWrapper, Map, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {DOM, Element, document} from 'angular2/src/facade/dom';
|
||||
import {document} from 'angular2/src/facade/browser';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
export function main() {
|
||||
var domEventPlugin;
|
||||
@@ -100,7 +101,7 @@ class FakeEventManagerPlugin extends EventManagerPlugin {
|
||||
return ListWrapper.contains(this._supports, eventName);
|
||||
}
|
||||
|
||||
addEventListener(element: Element, eventName: string, handler: Function, shouldSupportBubble: boolean) {
|
||||
addEventListener(element, eventName: string, handler: Function, shouldSupportBubble: boolean) {
|
||||
MapWrapper.set(shouldSupportBubble ? this._bubbleEventHandlers : this._nonBubbleEventHandlers,
|
||||
eventName, handler);
|
||||
}
|
||||
|
||||
Vendored
-1
@@ -2,7 +2,6 @@ import {describe, iit, it, expect, beforeEach} from 'angular2/test_lib';
|
||||
import {Key, KeyRegistry} from 'angular2/di';
|
||||
|
||||
export function main() {
|
||||
|
||||
describe("key", function () {
|
||||
var registry;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular2/test_lib';
|
||||
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {Injector} from 'angular2/di';
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import {describe, xit, it, expect, beforeEach, ddescribe, iit, el, IS_DARTIUM} from 'angular2/test_lib';
|
||||
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {Injector} from 'angular2/di';
|
||||
import {Lexer, Parser, ChangeDetector, dynamicChangeDetection} from 'angular2/change_detection';
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular2/test_lib';
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {Injector} from 'angular2/di';
|
||||
import {Lexer, Parser, ChangeDetector, dynamicChangeDetection} from 'angular2/change_detection';
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular2/test_lib';
|
||||
import {DOM} from 'angular2/src/facade/dom';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {Injector} from 'angular2/di';
|
||||
import {Lexer, Parser, dynamicChangeDetection} from 'angular2/change_detection';
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
library angular2.dom.html5lib_adapter.test;
|
||||
|
||||
import 'package:guinness/guinness.dart';
|
||||
import 'package:unittest/unittest.dart' hide expect;
|
||||
import 'package:angular2/src/dom/html5lib_adapter.dart';
|
||||
|
||||
// A smoke-test of the adapter. It is primarily tested by the compiler.
|
||||
main() {
|
||||
describe('Html5Lib DOM Adapter', () {
|
||||
Html5LibDomAdapter subject;
|
||||
|
||||
beforeEach(() {
|
||||
subject = new Html5LibDomAdapter();
|
||||
});
|
||||
|
||||
it('should parse HTML', () {
|
||||
expect(subject.parse('<div>hi</div>'), isNotNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user