parent
ab5ed6f2ec
commit
2ff2ce3c6c
|
@ -234,7 +234,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||||
return node.nodeType === Node.TEXT_NODE;
|
return node.nodeType === Node.TEXT_NODE;
|
||||||
}
|
}
|
||||||
isCommentNode(node:Node):boolean {
|
isCommentNode(node:Node):boolean {
|
||||||
return node.nodeType === Node.TEXT_NODE;
|
return node.nodeType === Node.COMMENT_NODE;
|
||||||
}
|
}
|
||||||
isElementNode(node:Node):boolean {
|
isElementNode(node:Node):boolean {
|
||||||
return node.nodeType === Node.ELEMENT_NODE;
|
return node.nodeType === Node.ELEMENT_NODE;
|
||||||
|
|
|
@ -144,6 +144,9 @@ export class DomAdapter {
|
||||||
getShadowRoot(el) {
|
getShadowRoot(el) {
|
||||||
throw _abstract();
|
throw _abstract();
|
||||||
}
|
}
|
||||||
|
getDistributedNodes(el) {
|
||||||
|
throw _abstract();
|
||||||
|
}
|
||||||
clone(node) {
|
clone(node) {
|
||||||
throw _abstract();
|
throw _abstract();
|
||||||
}
|
}
|
||||||
|
@ -249,4 +252,10 @@ export class DomAdapter {
|
||||||
cssToRules(css:string): List {
|
cssToRules(css:string): List {
|
||||||
throw _abstract();
|
throw _abstract();
|
||||||
}
|
}
|
||||||
|
supportsDOMEvents(): boolean {
|
||||||
|
throw _abstract();
|
||||||
|
}
|
||||||
|
supportsNativeShadowDOM(): boolean {
|
||||||
|
throw _abstract();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {ABSTRACT} from 'angular2/src/facade/lang';
|
import {ABSTRACT} from 'angular2/src/facade/lang';
|
||||||
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {isPresent} from 'angular2/src/facade/lang';
|
import {isPresent, isFunction} from 'angular2/src/facade/lang';
|
||||||
import {DomAdapter} from './dom_adapter';
|
import {DomAdapter} from './dom_adapter';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,6 +8,9 @@ import {DomAdapter} from './dom_adapter';
|
||||||
*/
|
*/
|
||||||
@ABSTRACT()
|
@ABSTRACT()
|
||||||
export class GenericBrowserDomAdapter extends DomAdapter {
|
export class GenericBrowserDomAdapter extends DomAdapter {
|
||||||
|
getDistributedNodes(el) {
|
||||||
|
return el.getDistributedNodes();
|
||||||
|
}
|
||||||
resolveAndSetHref(el, baseUrl:string, href:string) {
|
resolveAndSetHref(el, baseUrl:string, href:string) {
|
||||||
el.href = href == null ? baseUrl : baseUrl + '/../' + href;
|
el.href = href == null ? baseUrl : baseUrl + '/../' + href;
|
||||||
}
|
}
|
||||||
|
@ -34,4 +37,10 @@ export class GenericBrowserDomAdapter extends DomAdapter {
|
||||||
this.remove(style);
|
this.remove(style);
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
supportsDOMEvents(): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
supportsNativeShadowDOM(): boolean {
|
||||||
|
return isFunction(this.defaultDoc().body.createShadowRoot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,4 +223,13 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||||
List cssToRules(String css) {
|
List cssToRules(String css) {
|
||||||
throw 'not implemented';
|
throw 'not implemented';
|
||||||
}
|
}
|
||||||
|
List getDistributedNodes(Node) {
|
||||||
|
throw 'not implemented';
|
||||||
|
}
|
||||||
|
bool supportsDOMEvents() {
|
||||||
|
throw 'not implemented';
|
||||||
|
}
|
||||||
|
bool supportsNativeShadowDOM() {
|
||||||
|
throw 'not implemented';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ var parser = new parse5.Parser(parse5.TreeAdapters.htmlparser2);
|
||||||
var serializer = new parse5.Serializer(parse5.TreeAdapters.htmlparser2);
|
var serializer = new parse5.Serializer(parse5.TreeAdapters.htmlparser2);
|
||||||
var treeAdapter = parser.treeAdapter;
|
var treeAdapter = parser.treeAdapter;
|
||||||
|
|
||||||
var cssParse = require('css-parse');
|
var cssParse = require('css').parse;
|
||||||
|
|
||||||
var url = require('url');
|
var url = require('url');
|
||||||
|
|
||||||
|
@ -252,6 +252,9 @@ export class Parse5DomAdapter extends DomAdapter {
|
||||||
getShadowRoot(el) {
|
getShadowRoot(el) {
|
||||||
return el.shadowRoot;
|
return el.shadowRoot;
|
||||||
}
|
}
|
||||||
|
getDistributedNodes(el) {
|
||||||
|
throw _notImplemented('getDistributedNodes');
|
||||||
|
}
|
||||||
clone(node) {
|
clone(node) {
|
||||||
var temp = treeAdapter.createElement("template", null, []);
|
var temp = treeAdapter.createElement("template", null, []);
|
||||||
treeAdapter.appendChild(temp, node);
|
treeAdapter.appendChild(temp, node);
|
||||||
|
@ -384,7 +387,7 @@ export class Parse5DomAdapter extends DomAdapter {
|
||||||
return treeAdapter.isTextNode(node);
|
return treeAdapter.isTextNode(node);
|
||||||
}
|
}
|
||||||
isCommentNode(node):boolean {
|
isCommentNode(node):boolean {
|
||||||
throw treeAdapter.isCommentNode(node);
|
return treeAdapter.isCommentNode(node);
|
||||||
}
|
}
|
||||||
isElementNode(node):boolean {
|
isElementNode(node):boolean {
|
||||||
return node ? treeAdapter.isElementNode(node) : false;
|
return node ? treeAdapter.isElementNode(node) : false;
|
||||||
|
@ -455,6 +458,12 @@ export class Parse5DomAdapter extends DomAdapter {
|
||||||
}
|
}
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
supportsDOMEvents(): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
supportsNativeShadowDOM(): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: build a proper list, this one is all the keys of a HTMLInputElement
|
//TODO: build a proper list, this one is all the keys of a HTMLInputElement
|
||||||
|
|
|
@ -24,6 +24,7 @@ class IMPLEMENTS {
|
||||||
bool isPresent(obj) => obj != null;
|
bool isPresent(obj) => obj != null;
|
||||||
bool isBlank(obj) => obj == null;
|
bool isBlank(obj) => obj == null;
|
||||||
bool isString(obj) => obj is String;
|
bool isString(obj) => obj is String;
|
||||||
|
bool isFunction(obj) => obj is Function;
|
||||||
|
|
||||||
String stringify(obj) => obj.toString();
|
String stringify(obj) => obj.toString();
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,10 @@ export function isString(obj):boolean {
|
||||||
return typeof obj === "string";
|
return typeof obj === "string";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isFunction(obj):boolean {
|
||||||
|
return typeof obj === "function";
|
||||||
|
}
|
||||||
|
|
||||||
export function stringify(token):string {
|
export function stringify(token):string {
|
||||||
if (typeof token === 'string') {
|
if (typeof token === 'string') {
|
||||||
return token;
|
return token;
|
||||||
|
|
|
@ -18,7 +18,6 @@ import './test_injector.dart';
|
||||||
export './test_injector.dart' show inject;
|
export './test_injector.dart' show inject;
|
||||||
|
|
||||||
bool IS_DARTIUM = true;
|
bool IS_DARTIUM = true;
|
||||||
bool IS_NODEJS = false;
|
|
||||||
|
|
||||||
List _testBindings = [];
|
List _testBindings = [];
|
||||||
Injector _injector;
|
Injector _injector;
|
||||||
|
@ -165,11 +164,11 @@ String elementText(n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DOM.isElementNode(n) && DOM.tagName(n) == 'CONTENT') {
|
if (DOM.isElementNode(n) && DOM.tagName(n) == 'CONTENT') {
|
||||||
return elementText(n.getDistributedNodes());
|
return elementText(DOM.getDistributedNodes(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DOM.hasShadowRoot(n)) {
|
if (DOM.hasShadowRoot(n)) {
|
||||||
return elementText(DOM.childNodesAsList(n.shadowRoot));
|
return elementText(DOM.childNodesAsList(DOM.getShadowRoot(n)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNodes(n)) {
|
if (hasNodes(n)) {
|
||||||
|
|
|
@ -14,7 +14,6 @@ export var afterEach = _global.afterEach;
|
||||||
export var expect = _global.expect;
|
export var expect = _global.expect;
|
||||||
|
|
||||||
export var IS_DARTIUM = false;
|
export var IS_DARTIUM = false;
|
||||||
export var IS_NODEJS = typeof window === 'undefined';
|
|
||||||
|
|
||||||
export class AsyncTestCompleter {
|
export class AsyncTestCompleter {
|
||||||
_done: Function;
|
_done: Function;
|
||||||
|
@ -293,23 +292,26 @@ export class SpyObject {
|
||||||
|
|
||||||
function elementText(n) {
|
function elementText(n) {
|
||||||
var hasNodes = (n) => {var children = DOM.childNodes(n); return children && children.length > 0;}
|
var hasNodes = (n) => {var children = DOM.childNodes(n); return children && children.length > 0;}
|
||||||
if (!IS_NODEJS) {
|
|
||||||
if (n instanceof Comment) return '';
|
|
||||||
|
|
||||||
if (n instanceof Array) return n.map((nn) => elementText(nn)).join("");
|
if (n instanceof Array) {
|
||||||
if (n instanceof Element && DOM.tagName(n) == 'CONTENT')
|
return n.map((nn) => elementText(nn)).join("");
|
||||||
return elementText(Array.prototype.slice.apply(n.getDistributedNodes()));
|
|
||||||
if (DOM.hasShadowRoot(n)) return elementText(DOM.childNodesAsList(n.shadowRoot));
|
|
||||||
if (hasNodes(n)) return elementText(DOM.childNodesAsList(n));
|
|
||||||
|
|
||||||
return n.textContent;
|
|
||||||
} else {
|
|
||||||
if (n instanceof Array) {
|
|
||||||
return n.map((nn) => elementText(nn)).join("");
|
|
||||||
} else if (hasNodes(n)) {
|
|
||||||
return elementText(DOM.childNodesAsList(n));
|
|
||||||
} else {
|
|
||||||
return DOM.getText(n);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DOM.isCommentNode(n)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DOM.isElementNode(n) && DOM.tagName(n) == 'CONTENT') {
|
||||||
|
return elementText(Array.prototype.slice.apply(DOM.getDistributedNodes(n)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DOM.hasShadowRoot(n)) {
|
||||||
|
return elementText(DOM.childNodesAsList(DOM.getShadowRoot(n)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasNodes(n)) {
|
||||||
|
return elementText(DOM.childNodesAsList(n));
|
||||||
|
}
|
||||||
|
|
||||||
|
return DOM.getText(n);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {describe, beforeEach, it, expect, ddescribe, iit, SpyObject, el, IS_NODEJS} from 'angular2/test_lib';
|
import {describe, beforeEach, it, expect, ddescribe, iit, SpyObject, el} from 'angular2/test_lib';
|
||||||
import {ShadowCss} from 'angular2/src/core/compiler/shadow_dom_emulation/shadow_css';
|
import {ShadowCss} from 'angular2/src/core/compiler/shadow_dom_emulation/shadow_css';
|
||||||
|
|
||||||
import {RegExpWrapper, StringWrapper} from 'angular2/src/facade/lang';
|
import {RegExpWrapper, StringWrapper} from 'angular2/src/facade/lang';
|
||||||
|
@ -91,16 +91,13 @@ export function main() {
|
||||||
expect(StringWrapper.contains(css, '#menu > .bar {;background: blue;}')).toBeTruthy();
|
expect(StringWrapper.contains(css, '#menu > .bar {;background: blue;}')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!IS_NODEJS) {
|
it('should support polyfill-rule', () => {
|
||||||
//TODO: reactivate once CSS parser is fixed: https://github.com/reworkcss/css/issues/65
|
var css = s("polyfill-rule {content: ':host.foo .bar';background: blue;}", 'a', 'a-host');
|
||||||
it('should support polyfill-rule', () => {
|
expect(css).toEqual('[a-host].foo .bar {background: blue;}');
|
||||||
var css = s("polyfill-rule {content: ':host.foo .bar';background: blue;}", 'a', 'a-host');
|
|
||||||
expect(css).toEqual('[a-host].foo .bar {background: blue;}');
|
|
||||||
|
|
||||||
css = s('polyfill-rule {content: ":host.foo .bar";background: blue;}', 'a', 'a-host');
|
css = s('polyfill-rule {content: ":host.foo .bar";background: blue;}', 'a', 'a-host');
|
||||||
expect(css).toEqual('[a-host].foo .bar {background: blue;}');
|
expect(css).toEqual('[a-host].foo .bar {background: blue;}');
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
it('should handle ::shadow', () => {
|
it('should handle ::shadow', () => {
|
||||||
var css = s('x::shadow > y {}', 'a');
|
var css = s('x::shadow > y {}', 'a');
|
||||||
|
|
|
@ -7,7 +7,6 @@ import {
|
||||||
expect,
|
expect,
|
||||||
iit,
|
iit,
|
||||||
inject,
|
inject,
|
||||||
IS_NODEJS,
|
|
||||||
it,
|
it,
|
||||||
xit,
|
xit,
|
||||||
} from 'angular2/test_lib';
|
} from 'angular2/test_lib';
|
||||||
|
@ -54,7 +53,7 @@ export function main() {
|
||||||
"scoped" : new EmulatedScopedShadowDomStrategy(styleInliner, styleUrlResolver, DOM.createElement('div')),
|
"scoped" : new EmulatedScopedShadowDomStrategy(styleInliner, styleUrlResolver, DOM.createElement('div')),
|
||||||
"unscoped" : new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, DOM.createElement('div'))
|
"unscoped" : new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, DOM.createElement('div'))
|
||||||
}
|
}
|
||||||
if (!IS_NODEJS) {
|
if (DOM.supportsNativeShadowDOM()) {
|
||||||
StringMapWrapper.set(strategies, "native", new NativeShadowDomStrategy(styleUrlResolver));
|
StringMapWrapper.set(strategies, "native", new NativeShadowDomStrategy(styleUrlResolver));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {describe, xit, it, expect, beforeEach, ddescribe, iit, el, proxy, IS_NODEJS} from 'angular2/test_lib';
|
import {describe, xit, it, expect, beforeEach, ddescribe, iit, el, proxy} from 'angular2/test_lib';
|
||||||
import {ProtoView, ElementPropertyMemento, DirectivePropertyMemento} from 'angular2/src/core/compiler/view';
|
import {ProtoView, ElementPropertyMemento, DirectivePropertyMemento} from 'angular2/src/core/compiler/view';
|
||||||
import {ProtoElementInjector, ElementInjector, DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
import {ProtoElementInjector, ElementInjector, DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
||||||
import {EmulatedScopedShadowDomStrategy, NativeShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy';
|
import {EmulatedScopedShadowDomStrategy, NativeShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy';
|
||||||
|
@ -444,7 +444,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!IS_NODEJS) {
|
if (DOM.supportsDOMEvents()) {
|
||||||
describe('event handlers', () => {
|
describe('event handlers', () => {
|
||||||
var view, ctx, called, receivedEvent, dispatchedEvent;
|
var view, ctx, called, receivedEvent, dispatchedEvent;
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ import {
|
||||||
inject,
|
inject,
|
||||||
it,
|
it,
|
||||||
queryView,
|
queryView,
|
||||||
xit,
|
xit
|
||||||
IS_NODEJS
|
|
||||||
} from 'angular2/test_lib';
|
} from 'angular2/test_lib';
|
||||||
|
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||||
|
|
||||||
import {Lexer, Parser, ChangeDetector, dynamicChangeDetection} from 'angular2/change_detection';
|
import {Lexer, Parser, ChangeDetector, dynamicChangeDetection} from 'angular2/change_detection';
|
||||||
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
||||||
|
@ -86,7 +86,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (!IS_NODEJS) {
|
if (DOM.supportsDOMEvents()) {
|
||||||
it("should update the control group values on DOM change", inject([AsyncTestCompleter], (async) => {
|
it("should update the control group values on DOM change", inject([AsyncTestCompleter], (async) => {
|
||||||
var form = new ControlGroup({
|
var form = new ControlGroup({
|
||||||
"login": new Control("oldValue")
|
"login": new Control("oldValue")
|
||||||
|
@ -153,7 +153,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (!IS_NODEJS) {
|
if (DOM.supportsDOMEvents()) {
|
||||||
describe("different control types", () => {
|
describe("different control types", () => {
|
||||||
it("should support type=checkbox", inject([AsyncTestCompleter], (async) => {
|
it("should support type=checkbox", inject([AsyncTestCompleter], (async) => {
|
||||||
var ctx = new MyComp(new ControlGroup({"checkbox": new Control(true)}));
|
var ctx = new MyComp(new ControlGroup({"checkbox": new Control(true)}));
|
||||||
|
@ -305,7 +305,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (!IS_NODEJS) {
|
if (DOM.supportsDOMEvents()) {
|
||||||
it("should update the control group values on DOM change", inject([AsyncTestCompleter], (async) => {
|
it("should update the control group values on DOM change", inject([AsyncTestCompleter], (async) => {
|
||||||
var form = new ControlGroup({
|
var form = new ControlGroup({
|
||||||
"nested": new ControlGroup({
|
"nested": new ControlGroup({
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
"angular": "1.3.5",
|
"angular": "1.3.5",
|
||||||
"bower": "^1.3.12",
|
"bower": "^1.3.12",
|
||||||
"canonical-path": "0.0.2",
|
"canonical-path": "0.0.2",
|
||||||
"css-parse": "2.0.0",
|
"css": "mlaval/css#issue65",
|
||||||
"del": "~1",
|
"del": "~1",
|
||||||
"dgeni": "^0.4.1",
|
"dgeni": "^0.4.1",
|
||||||
"dgeni-packages": "^0.10.11",
|
"dgeni-packages": "^0.10.11",
|
||||||
|
|
Loading…
Reference in New Issue