fix(deps): Update clang-format to 1.0.14.

This commit is contained in:
Martin Probst 2015-05-21 16:42:19 +02:00 committed by Tobias Bosch
parent e50f537667
commit 15f1eb28a2
15 changed files with 519 additions and 631 deletions

View File

@ -89,7 +89,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
bind(appComponentType).toFactory((ref) => ref.instance, [appComponentRefToken]),
bind(LifeCycle)
.toFactory((exceptionHandler) => new LifeCycle(exceptionHandler, null, assertionsEnabled()),
[ExceptionHandler]),
[ExceptionHandler]),
bind(EventManager)
.toFactory(
(ngZone) =>
@ -142,15 +142,15 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
function _createNgZone(givenReporter: Function): NgZone {
var defaultErrorReporter = (exception, stackTrace) => {
var longStackTrace = ListWrapper.join(stackTrace, "\n\n-----async gap-----\n");
DOM.logError(`${exception}\n\n${longStackTrace}`);
throw exception;
};
DOM.logError(`${exception}\n\n${longStackTrace}`);
throw exception;
};
var reporter = isPresent(givenReporter) ? givenReporter : defaultErrorReporter;
var reporter = isPresent(givenReporter) ? givenReporter : defaultErrorReporter;
var zone = new NgZone({enableLongStackTrace: assertionsEnabled()});
zone.initCallbacks({onErrorHandler: reporter});
return zone;
var zone = new NgZone({enableLongStackTrace: assertionsEnabled()});
zone.initCallbacks({onErrorHandler: reporter});
return zone;
}
/**

View File

@ -175,84 +175,83 @@ export class Compiler {
var nestedPVPromises = [];
ListWrapper.forEach(this._collectComponentElementBinders(protoViews), (elementBinder) => {
var nestedComponent = elementBinder.componentDirective;
var elementBinderDone = (nestedPv: AppProtoView) => {
elementBinder.nestedProtoView = nestedPv;
};
var elementBinderDone =
(nestedPv: AppProtoView) => { elementBinder.nestedProtoView = nestedPv; };
var nestedCall = this._compile(nestedComponent);
if (PromiseWrapper.isPromise(nestedCall)) {
ListWrapper.push(nestedPVPromises,
(<Promise<AppProtoView>>nestedCall).then(elementBinderDone));
ListWrapper.push(nestedPVPromises,
(<Promise<AppProtoView>>nestedCall).then(elementBinderDone));
} else if (isPresent(nestedCall)) {
elementBinderDone(<AppProtoView>nestedCall);
}
});
if (nestedPVPromises.length > 0) {
return PromiseWrapper.all(nestedPVPromises).then((_) => protoView);
} else {
return protoView;
}
}
private _collectComponentElementBinders(protoViews: List<AppProtoView>): List<ElementBinder> {
var componentElementBinders = [];
ListWrapper.forEach(protoViews, (protoView) => {
ListWrapper.forEach(protoView.elementBinders, (elementBinder) => {
if (isPresent(elementBinder.componentDirective)) {
ListWrapper.push(componentElementBinders, elementBinder);
elementBinderDone(<AppProtoView>nestedCall);
}
});
});
return componentElementBinders;
}
private _buildRenderTemplate(component, view, directives): renderApi.ViewDefinition {
var componentUrl =
this._urlResolver.resolve(this._appUrl, this._componentUrlMapper.getUrl(component));
var templateAbsUrl = null;
if (isPresent(view.templateUrl)) {
templateAbsUrl = this._urlResolver.resolve(componentUrl, view.templateUrl);
} else if (isPresent(view.template)) {
// Note: If we have an inline template, we also need to send
// the url for the component to the render so that it
// is able to resolve urls in stylesheets.
templateAbsUrl = componentUrl;
}
return new renderApi.ViewDefinition({
componentId: stringify(component),
absUrl: templateAbsUrl, template: view.template,
directives: ListWrapper.map(directives, directiveBinding => directiveBinding.metadata)
});
}
private _flattenDirectives(template: View): List<Type> {
if (isBlank(template.directives)) return [];
var directives = [];
this._flattenList(template.directives, directives);
return directives;
}
private _flattenList(tree: List<any>, out: List<Type | Binding | List<any>>): void {
for (var i = 0; i < tree.length; i++) {
var item = resolveForwardRef(tree[i]);
if (ListWrapper.isList(item)) {
this._flattenList(item, out);
if (nestedPVPromises.length > 0) {
return PromiseWrapper.all(nestedPVPromises).then((_) => protoView);
} else {
ListWrapper.push(out, item);
return protoView;
}
}
private _collectComponentElementBinders(protoViews: List<AppProtoView>): List<ElementBinder> {
var componentElementBinders = [];
ListWrapper.forEach(protoViews, (protoView) => {
ListWrapper.forEach(protoView.elementBinders, (elementBinder) => {
if (isPresent(elementBinder.componentDirective)) {
ListWrapper.push(componentElementBinders, elementBinder);
}
});
});
return componentElementBinders;
}
private _buildRenderTemplate(component, view, directives): renderApi.ViewDefinition {
var componentUrl =
this._urlResolver.resolve(this._appUrl, this._componentUrlMapper.getUrl(component));
var templateAbsUrl = null;
if (isPresent(view.templateUrl)) {
templateAbsUrl = this._urlResolver.resolve(componentUrl, view.templateUrl);
} else if (isPresent(view.template)) {
// Note: If we have an inline template, we also need to send
// the url for the component to the render so that it
// is able to resolve urls in stylesheets.
templateAbsUrl = componentUrl;
}
return new renderApi.ViewDefinition({
componentId: stringify(component),
absUrl: templateAbsUrl, template: view.template,
directives: ListWrapper.map(directives, directiveBinding => directiveBinding.metadata)
});
}
private _flattenDirectives(template: View): List<Type> {
if (isBlank(template.directives)) return [];
var directives = [];
this._flattenList(template.directives, directives);
return directives;
}
private _flattenList(tree: List<any>, out: List<Type | Binding | List<any>>): void {
for (var i = 0; i < tree.length; i++) {
var item = resolveForwardRef(tree[i]);
if (ListWrapper.isList(item)) {
this._flattenList(item, out);
} else {
ListWrapper.push(out, item);
}
}
}
private static _isValidDirective(value: Type | Binding): boolean {
return isPresent(value) && (value instanceof Type || value instanceof Binding);
}
private static _assertTypeIsComponent(directiveBinding: DirectiveBinding): void {
if (directiveBinding.metadata.type !== renderApi.DirectiveMetadata.COMPONENT_TYPE) {
throw new BaseException(
`Could not load '${stringify(directiveBinding.key.token)}' because it is not a component.`);
}
}
}
private static _isValidDirective(value: Type | Binding): boolean {
return isPresent(value) && (value instanceof Type || value instanceof Binding);
}
private static _assertTypeIsComponent(directiveBinding: DirectiveBinding): void {
if (directiveBinding.metadata.type !== renderApi.DirectiveMetadata.COMPONENT_TYPE) {
throw new BaseException(
`Could not load '${stringify(directiveBinding.key.token)}' because it is not a component.`);
}
}
}

View File

@ -38,81 +38,85 @@ export class DynamicComponentLoader {
loadIntoExistingLocation(typeOrBinding, location: ElementRef,
injector: Injector = null): Promise<ComponentRef> {
var binding = this._getBinding(typeOrBinding);
return this._compiler.compile(binding.token).then(componentProtoViewRef => {
this._viewManager.createDynamicComponentView(location, componentProtoViewRef, binding,
injector);
var component = this._viewManager.getComponent(location);
var dispose = () => { throw new BaseException("Not implemented");};
return new ComponentRef(location, component, dispose);
});
}
/**
* Loads a root component that is placed at the first element that matches the
* component's selector.
* The loaded component receives injection normally as a hosted view.
*/
loadAsRoot(typeOrBinding, overrideSelector = null,
injector: Injector = null): Promise<ComponentRef> {
return this._compiler.compileInHost(this._getBinding(typeOrBinding)).then(hostProtoViewRef => {
var hostViewRef =
this._viewManager.createRootHostView(hostProtoViewRef, overrideSelector, injector);
var newLocation = new ElementRef(hostViewRef, 0);
var component = this._viewManager.getComponent(newLocation);
var dispose = () => { this._viewManager.destroyRootHostView(hostViewRef);
};
return new ComponentRef(newLocation, component, dispose);
});
}
/**
* Loads a component into a free host view that is not yet attached to
* a parent on the render side, although it is attached to a parent in the injector hierarchy.
* The loaded component receives injection normally as a hosted view.
*/
loadIntoNewLocation(typeOrBinding, parentComponentLocation: ElementRef,
injector: Injector = null): Promise<ComponentRef> {
return this._compiler.compileInHost(this._getBinding(typeOrBinding)).then(hostProtoViewRef => {
var hostViewRef =
this._viewManager.createFreeHostView(parentComponentLocation, hostProtoViewRef, injector);
var newLocation = new ElementRef(hostViewRef, 0);
var component = this._viewManager.getComponent(newLocation);
var dispose = () => {
this._viewManager.destroyFreeHostView(parentComponentLocation, hostViewRef);
};
return new ComponentRef(newLocation, component, dispose);
});
}
/**
* Loads a component next to the provided ElementRef. The loaded component receives
* injection normally as a hosted view.
*/
loadNextToExistingLocation(typeOrBinding, location: ElementRef,
injector: Injector = null): Promise<ComponentRef> {
var binding = this._getBinding(typeOrBinding);
return this._compiler.compileInHost(binding).then(hostProtoViewRef => {
var viewContainer = this._viewManager.getViewContainer(location);
var hostViewRef = viewContainer.create(hostProtoViewRef, viewContainer.length, null, injector);
var newLocation = new ElementRef(hostViewRef, 0);
var component = this._viewManager.getComponent(newLocation);
var dispose = () => { var index = viewContainer.indexOf(hostViewRef);
viewContainer.remove(index);
};
return new ComponentRef(newLocation, component, dispose);
});
}
private _getBinding(typeOrBinding): Binding {
var binding;
if (typeOrBinding instanceof Binding) {
binding = typeOrBinding;
} else {
binding = bind(typeOrBinding).toClass(typeOrBinding);
return this._compiler.compile(binding.token)
.then(componentProtoViewRef => {
this._viewManager.createDynamicComponentView(location, componentProtoViewRef, binding,
injector);
var component = this._viewManager.getComponent(location);
var dispose = () => { throw new BaseException("Not implemented"); };
return new ComponentRef(location, component, dispose);
});
}
/**
* Loads a root component that is placed at the first element that matches the
* component's selector.
* The loaded component receives injection normally as a hosted view.
*/
loadAsRoot(typeOrBinding, overrideSelector = null,
injector: Injector = null): Promise<ComponentRef> {
return this._compiler.compileInHost(this._getBinding(typeOrBinding))
.then(hostProtoViewRef => {
var hostViewRef =
this._viewManager.createRootHostView(hostProtoViewRef, overrideSelector, injector);
var newLocation = new ElementRef(hostViewRef, 0);
var component = this._viewManager.getComponent(newLocation);
var dispose = () => { this._viewManager.destroyRootHostView(hostViewRef); };
return new ComponentRef(newLocation, component, dispose);
});
}
/**
* Loads a component into a free host view that is not yet attached to
* a parent on the render side, although it is attached to a parent in the injector hierarchy.
* The loaded component receives injection normally as a hosted view.
*/
loadIntoNewLocation(typeOrBinding, parentComponentLocation: ElementRef,
injector: Injector = null): Promise<ComponentRef> {
return this._compiler.compileInHost(this._getBinding(typeOrBinding))
.then(hostProtoViewRef => {
var hostViewRef = this._viewManager.createFreeHostView(parentComponentLocation,
hostProtoViewRef, injector);
var newLocation = new ElementRef(hostViewRef, 0);
var component = this._viewManager.getComponent(newLocation);
var dispose = () => {
this._viewManager.destroyFreeHostView(parentComponentLocation, hostViewRef);
};
return new ComponentRef(newLocation, component, dispose);
});
}
/**
* Loads a component next to the provided ElementRef. The loaded component receives
* injection normally as a hosted view.
*/
loadNextToExistingLocation(typeOrBinding, location: ElementRef,
injector: Injector = null): Promise<ComponentRef> {
var binding = this._getBinding(typeOrBinding);
return this._compiler.compileInHost(binding).then(hostProtoViewRef => {
var viewContainer = this._viewManager.getViewContainer(location);
var hostViewRef =
viewContainer.create(hostProtoViewRef, viewContainer.length, null, injector);
var newLocation = new ElementRef(hostViewRef, 0);
var component = this._viewManager.getComponent(newLocation);
var dispose = () => {
var index = viewContainer.indexOf(hostViewRef);
viewContainer.remove(index);
};
return new ComponentRef(newLocation, component, dispose);
});
}
private _getBinding(typeOrBinding): Binding {
var binding;
if (typeOrBinding instanceof Binding) {
binding = typeOrBinding;
} else {
binding = bind(typeOrBinding).toClass(typeOrBinding);
}
return binding;
}
return binding;
}
}

View File

@ -39,43 +39,45 @@ export class LifeCycle {
constructor(exceptionHandler: ExceptionHandler, changeDetector: ChangeDetector = null,
enforceNoNewChanges: boolean = false) {
this._errorHandler = (exception, stackTrace) => { exceptionHandler.call(exception, stackTrace);
throw exception;
};
this._changeDetector =
changeDetector; // may be null when instantiated from application bootstrap
this._enforceNoNewChanges = enforceNoNewChanges;
}
/**
* @private
*/
registerWith(zone: NgZone, changeDetector: ChangeDetector = null) {
if (isPresent(changeDetector)) {
this._changeDetector = changeDetector;
this._errorHandler = (exception, stackTrace) => {
exceptionHandler.call(exception, stackTrace);
throw exception;
};
this._changeDetector =
changeDetector; // may be null when instantiated from application bootstrap
this._enforceNoNewChanges = enforceNoNewChanges;
}
zone.initCallbacks({onErrorHandler: this._errorHandler, onTurnDone: () => this.tick()});
}
/**
* @private
*/
registerWith(zone: NgZone, changeDetector: ChangeDetector = null) {
if (isPresent(changeDetector)) {
this._changeDetector = changeDetector;
}
/**
* Invoke this method to explicitly process change detection and its side-effects.
*
* In development mode, `tick()` also performs a second change detection cycle to ensure that no
* further
* changes are detected. If additional changes are picked up during this second cycle, bindings in
* the app have
* side-effects that cannot be resolved in a single change detection pass. In this case, Angular
* throws an error,
* since an Angular application can only have one change detection pass during which all change
* detection must
* complete.
*
*/
tick() {
this._changeDetector.detectChanges();
if (this._enforceNoNewChanges) {
this._changeDetector.checkNoChanges();
zone.initCallbacks({onErrorHandler: this._errorHandler, onTurnDone: () => this.tick()});
}
/**
* Invoke this method to explicitly process change detection and its side-effects.
*
* In development mode, `tick()` also performs a second change detection cycle to ensure that no
* further
* changes are detected. If additional changes are picked up during this second cycle, bindings
* in
* the app have
* side-effects that cannot be resolved in a single change detection pass. In this case, Angular
* throws an error,
* since an Angular application can only have one change detection pass during which all change
* detection must
* complete.
*
*/
tick() {
this._changeDetector.detectChanges();
if (this._enforceNoNewChanges) {
this._changeDetector.checkNoChanges();
}
}
}
}

View File

@ -61,7 +61,7 @@ export class AbstractBindingError extends BaseException {
export class NoBindingError extends AbstractBindingError {
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(key) {
super(key, function (keys:List<any>) {
super(key, function(keys: List<any>) {
var first = stringify(ListWrapper.first(keys).token);
return `No provider for ${first}!${constructResolvingPath(keys)}`;
});
@ -95,7 +95,7 @@ export class NoBindingError extends AbstractBindingError {
export class AsyncBindingError extends AbstractBindingError {
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(key) {
super(key, function (keys:List<any>) {
super(key, function(keys: List<any>) {
var first = stringify(ListWrapper.first(keys).token);
return `Cannot instantiate ${first} synchronously. It is provided as a promise!${constructResolvingPath(keys)}`;
});
@ -123,7 +123,7 @@ export class AsyncBindingError extends AbstractBindingError {
export class CyclicDependencyError extends AbstractBindingError {
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(key) {
super(key, function (keys:List<any>) {
super(key, function(keys: List<any>) {
return `Cannot instantiate cyclic dependency!${constructResolvingPath(keys)}`;
});
}
@ -142,7 +142,7 @@ export class InstantiationError extends AbstractBindingError {
causeKey;
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
constructor(cause, key) {
super(key, function (keys:List<any>) {
super(key, function(keys: List<any>) {
var first = stringify(ListWrapper.first(keys).token);
return `Error during instantiation of ${first}!${constructResolvingPath(keys)}. ORIGINAL ERROR: ${cause}`;
});

View File

@ -63,318 +63,197 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
el.addEventListener(evt, listener, false);
// Needed to follow Dart's subscription semantic, until fix of
// https://code.google.com/p/dart/issues/detail?id=17406
return () => { el.removeEventListener(evt, listener, false);
};
}
dispatchEvent(el, evt) {
el.dispatchEvent(evt);
}
createMouseEvent(eventType: string): MouseEvent {
var evt: MouseEvent = document.createEvent('MouseEvent');
evt.initEvent(eventType, true, true);
return evt;
}
createEvent(eventType): Event {
var evt: Event = document.createEvent('Event');
evt.initEvent(eventType, true, true);
return evt;
}
preventDefault(evt: Event) {
evt.preventDefault();
evt.returnValue = false;
}
getInnerHTML(el) {
return el.innerHTML;
}
getOuterHTML(el) {
return el.outerHTML;
}
nodeName(node: Node): string {
return node.nodeName;
}
nodeValue(node: Node): string {
return node.nodeValue;
}
type(node: HTMLInputElement): string {
return node.type;
}
content(node: Node): Node {
if (this.hasProperty(node, "content")) {
return (<any>node).content;
} else {
return node;
return () => { el.removeEventListener(evt, listener, false); };
}
}
firstChild(el): Node {
return el.firstChild;
}
nextSibling(el): Node {
return el.nextSibling;
}
parentElement(el) {
return el.parentElement;
}
childNodes(el): List<Node> {
return el.childNodes;
}
childNodesAsList(el): List<any> {
var childNodes = el.childNodes;
var res = ListWrapper.createFixedSize(childNodes.length);
for (var i = 0; i < childNodes.length; i++) {
res[i] = childNodes[i];
dispatchEvent(el, evt) { el.dispatchEvent(evt); }
createMouseEvent(eventType: string): MouseEvent {
var evt: MouseEvent = document.createEvent('MouseEvent');
evt.initEvent(eventType, true, true);
return evt;
}
return res;
}
clearNodes(el) {
for (var i = 0; i < el.childNodes.length; i++) {
this.remove(el.childNodes[i]);
createEvent(eventType): Event {
var evt: Event = document.createEvent('Event');
evt.initEvent(eventType, true, true);
return evt;
}
}
appendChild(el, node) {
el.appendChild(node);
}
removeChild(el, node) {
el.removeChild(node);
}
replaceChild(el: Node, newChild, oldChild) {
el.replaceChild(newChild, oldChild);
}
remove(el) {
var parent = el.parentNode;
parent.removeChild(el);
return el;
}
insertBefore(el, node) {
el.parentNode.insertBefore(node, el);
}
insertAllBefore(el, nodes) {
ListWrapper.forEach(nodes, (n) => { el.parentNode.insertBefore(n, el); });
}
insertAfter(el, node) {
el.parentNode.insertBefore(node, el.nextSibling);
}
setInnerHTML(el, value) {
el.innerHTML = value;
}
getText(el) {
return el.textContent;
}
// TODO(vicb): removed Element type because it does not support StyleElement
setText(el, value: string) {
el.textContent = value;
}
getValue(el) {
return el.value;
}
setValue(el, value: string) {
el.value = value;
}
getChecked(el) {
return el.checked;
}
setChecked(el, value: boolean) {
el.checked = value;
}
createTemplate(html): HTMLElement {
var t = document.createElement('template');
t.innerHTML = html;
return t;
}
createElement(tagName, doc = document): HTMLElement {
return doc.createElement(tagName);
}
createTextNode(text: string, doc = document): Text {
return doc.createTextNode(text);
}
createScriptTag(attrName: string, attrValue: string, doc = document): HTMLScriptElement {
var el = <HTMLScriptElement>doc.createElement('SCRIPT');
el.setAttribute(attrName, attrValue);
return el;
}
createStyleElement(css: string, doc = document): HTMLStyleElement {
var style = <HTMLStyleElement>doc.createElement('style');
this.appendChild(style, this.createTextNode(css));
return style;
}
createShadowRoot(el: HTMLElement): DocumentFragment {
return (<any>el).createShadowRoot();
}
getShadowRoot(el: HTMLElement): DocumentFragment {
return (<any>el).shadowRoot;
}
getHost(el: HTMLElement): HTMLElement {
return (<any>el).host;
}
clone(node: Node) {
return node.cloneNode(true);
}
hasProperty(element, name: string) {
return name in element;
}
getElementsByClassName(element, name: string) {
return element.getElementsByClassName(name);
}
getElementsByTagName(element, name: string) {
return element.getElementsByTagName(name);
}
classList(element): List<any> {
return <List<any>>Array.prototype.slice.call(element.classList, 0);
}
addClass(element, classname: string) {
element.classList.add(classname);
}
removeClass(element, classname: string) {
element.classList.remove(classname);
}
hasClass(element, classname: string) {
return element.classList.contains(classname);
}
setStyle(element, stylename: string, stylevalue: string) {
element.style[stylename] = stylevalue;
}
removeStyle(element, stylename: string) {
element.style[stylename] = null;
}
getStyle(element, stylename: string) {
return element.style[stylename];
}
tagName(element): string {
return element.tagName;
}
attributeMap(element) {
var res = MapWrapper.create();
var elAttrs = element.attributes;
for (var i = 0; i < elAttrs.length; i++) {
var attrib = elAttrs[i];
MapWrapper.set(res, attrib.name, attrib.value);
preventDefault(evt: Event) {
evt.preventDefault();
evt.returnValue = false;
}
return res;
}
hasAttribute(element, attribute: string) {
return element.hasAttribute(attribute);
}
getAttribute(element, attribute: string) {
return element.getAttribute(attribute);
}
setAttribute(element, name: string, value: string) {
element.setAttribute(name, value);
}
removeAttribute(element, attribute: string) {
return element.removeAttribute(attribute);
}
templateAwareRoot(el) {
return this.isTemplateElement(el) ? this.content(el) : el;
}
createHtmlDocument() {
return document.implementation.createHTMLDocument('fakeTitle');
}
defaultDoc() {
return document;
}
getBoundingClientRect(el) {
try {
return el.getBoundingClientRect();
} catch (e) {
return {top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0};
}
}
getTitle(): string {
return document.title;
}
setTitle(newTitle: string) {
document.title = newTitle || '';
}
elementMatches(n, selector: string): boolean {
return n instanceof HTMLElement && n.matches ? n.matches(selector) :
n.msMatchesSelector(selector);
}
isTemplateElement(el: any): boolean {
return el instanceof HTMLElement && el.nodeName == "TEMPLATE";
}
isTextNode(node: Node): boolean {
return node.nodeType === Node.TEXT_NODE;
}
isCommentNode(node: Node): boolean {
return node.nodeType === Node.COMMENT_NODE;
}
isElementNode(node: Node): boolean {
return node.nodeType === Node.ELEMENT_NODE;
}
hasShadowRoot(node): boolean {
return node instanceof HTMLElement && isPresent(node.shadowRoot);
}
isShadowRoot(node): boolean {
return node instanceof DocumentFragment;
}
importIntoDoc(node: Node) {
var toImport = node;
if (this.isTemplateElement(node)) {
toImport = this.content(node);
}
return document.importNode(toImport, true);
}
isPageRule(rule): boolean {
return rule.type === CSSRule.PAGE_RULE;
}
isStyleRule(rule): boolean {
return rule.type === CSSRule.STYLE_RULE;
}
isMediaRule(rule): boolean {
return rule.type === CSSRule.MEDIA_RULE;
}
isKeyframesRule(rule): boolean {
return rule.type === CSSRule.KEYFRAMES_RULE;
}
getHref(el: Element): string {
return (<any>el).href;
}
getEventKey(event): string {
var key = event.key;
if (isBlank(key)) {
key = event.keyIdentifier;
// keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
// Safari
// cf
// http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
if (isBlank(key)) {
return 'Unidentified';
getInnerHTML(el) { return el.innerHTML; }
getOuterHTML(el) { return el.outerHTML; }
nodeName(node: Node): string { return node.nodeName; }
nodeValue(node: Node): string { return node.nodeValue; }
type(node: HTMLInputElement): string { return node.type; }
content(node: Node): Node {
if (this.hasProperty(node, "content")) {
return (<any>node).content;
} else {
return node;
}
if (key.startsWith('U+')) {
key = String.fromCharCode(parseInt(key.substring(2), 16));
if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
// There is a bug in Chrome for numeric keypad keys:
// https://code.google.com/p/chromium/issues/detail?id=155654
// 1, 2, 3 ... are reported as A, B, C ...
key = _chromeNumKeyPadMap[key];
}
firstChild(el): Node { return el.firstChild; }
nextSibling(el): Node { return el.nextSibling; }
parentElement(el) { return el.parentElement; }
childNodes(el): List<Node> { return el.childNodes; }
childNodesAsList(el): List<any> {
var childNodes = el.childNodes;
var res = ListWrapper.createFixedSize(childNodes.length);
for (var i = 0; i < childNodes.length; i++) {
res[i] = childNodes[i];
}
return res;
}
clearNodes(el) {
for (var i = 0; i < el.childNodes.length; i++) {
this.remove(el.childNodes[i]);
}
}
appendChild(el, node) { el.appendChild(node); }
removeChild(el, node) { el.removeChild(node); }
replaceChild(el: Node, newChild, oldChild) { el.replaceChild(newChild, oldChild); }
remove(el) {
var parent = el.parentNode;
parent.removeChild(el);
return el;
}
insertBefore(el, node) { el.parentNode.insertBefore(node, el); }
insertAllBefore(el, nodes) {
ListWrapper.forEach(nodes, (n) => { el.parentNode.insertBefore(n, el); });
}
insertAfter(el, node) { el.parentNode.insertBefore(node, el.nextSibling); }
setInnerHTML(el, value) { el.innerHTML = value; }
getText(el) { return el.textContent; }
// TODO(vicb): removed Element type because it does not support StyleElement
setText(el, value: string) { el.textContent = value; }
getValue(el) { return el.value; }
setValue(el, value: string) { el.value = value; }
getChecked(el) { return el.checked; }
setChecked(el, value: boolean) { el.checked = value; }
createTemplate(html): HTMLElement {
var t = document.createElement('template');
t.innerHTML = html;
return t;
}
createElement(tagName, doc = document): HTMLElement { return doc.createElement(tagName); }
createTextNode(text: string, doc = document): Text { return doc.createTextNode(text); }
createScriptTag(attrName: string, attrValue: string, doc = document): HTMLScriptElement {
var el = <HTMLScriptElement>doc.createElement('SCRIPT');
el.setAttribute(attrName, attrValue);
return el;
}
createStyleElement(css: string, doc = document): HTMLStyleElement {
var style = <HTMLStyleElement>doc.createElement('style');
this.appendChild(style, this.createTextNode(css));
return style;
}
createShadowRoot(el: HTMLElement): DocumentFragment { return (<any>el).createShadowRoot(); }
getShadowRoot(el: HTMLElement): DocumentFragment { return (<any>el).shadowRoot; }
getHost(el: HTMLElement): HTMLElement { return (<any>el).host; }
clone(node: Node) { return node.cloneNode(true); }
hasProperty(element, name: string) { return name in element; }
getElementsByClassName(element, name: string) { return element.getElementsByClassName(name); }
getElementsByTagName(element, name: string) { return element.getElementsByTagName(name); }
classList(element): List<any> {
return <List<any>>Array.prototype.slice.call(element.classList, 0);
}
addClass(element, classname: string) { element.classList.add(classname); }
removeClass(element, classname: string) { element.classList.remove(classname); }
hasClass(element, classname: string) { return element.classList.contains(classname); }
setStyle(element, stylename: string, stylevalue: string) {
element.style[stylename] = stylevalue;
}
removeStyle(element, stylename: string) { element.style[stylename] = null; }
getStyle(element, stylename: string) { return element.style[stylename]; }
tagName(element): string { return element.tagName; }
attributeMap(element) {
var res = MapWrapper.create();
var elAttrs = element.attributes;
for (var i = 0; i < elAttrs.length; i++) {
var attrib = elAttrs[i];
MapWrapper.set(res, attrib.name, attrib.value);
}
return res;
}
hasAttribute(element, attribute: string) { return element.hasAttribute(attribute); }
getAttribute(element, attribute: string) { return element.getAttribute(attribute); }
setAttribute(element, name: string, value: string) { element.setAttribute(name, value); }
removeAttribute(element, attribute: string) { return element.removeAttribute(attribute); }
templateAwareRoot(el) { return this.isTemplateElement(el) ? this.content(el) : el; }
createHtmlDocument() { return document.implementation.createHTMLDocument('fakeTitle'); }
defaultDoc() { return document; }
getBoundingClientRect(el) {
try {
return el.getBoundingClientRect();
} catch (e) {
return {top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0};
}
}
getTitle(): string { return document.title; }
setTitle(newTitle: string) { document.title = newTitle || ''; }
elementMatches(n, selector: string): boolean {
return n instanceof HTMLElement && n.matches ? n.matches(selector) :
n.msMatchesSelector(selector);
}
isTemplateElement(el: any): boolean {
return el instanceof HTMLElement && el.nodeName == "TEMPLATE";
}
isTextNode(node: Node): boolean { return node.nodeType === Node.TEXT_NODE; }
isCommentNode(node: Node): boolean { return node.nodeType === Node.COMMENT_NODE; }
isElementNode(node: Node): boolean { return node.nodeType === Node.ELEMENT_NODE; }
hasShadowRoot(node): boolean { return node instanceof HTMLElement && isPresent(node.shadowRoot); }
isShadowRoot(node): boolean { return node instanceof DocumentFragment; }
importIntoDoc(node: Node) {
var toImport = node;
if (this.isTemplateElement(node)) {
toImport = this.content(node);
}
return document.importNode(toImport, true);
}
isPageRule(rule): boolean { return rule.type === CSSRule.PAGE_RULE; }
isStyleRule(rule): boolean { return rule.type === CSSRule.STYLE_RULE; }
isMediaRule(rule): boolean { return rule.type === CSSRule.MEDIA_RULE; }
isKeyframesRule(rule): boolean { return rule.type === CSSRule.KEYFRAMES_RULE; }
getHref(el: Element): string { return (<any>el).href; }
getEventKey(event): string {
var key = event.key;
if (isBlank(key)) {
key = event.keyIdentifier;
// keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
// Safari
// cf
// http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
if (isBlank(key)) {
return 'Unidentified';
}
if (key.startsWith('U+')) {
key = String.fromCharCode(parseInt(key.substring(2), 16));
if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
// There is a bug in Chrome for numeric keypad keys:
// https://code.google.com/p/chromium/issues/detail?id=155654
// 1, 2, 3 ... are reported as A, B, C ...
key = _chromeNumKeyPadMap[key];
}
}
}
if (_keyMap.hasOwnProperty(key)) {
key = _keyMap[key];
}
return key;
}
if (_keyMap.hasOwnProperty(key)) {
key = _keyMap[key];
getGlobalEventTarget(target: string): EventTarget {
if (target == "window") {
return window;
} else if (target == "document") {
return document;
} else if (target == "body") {
return document.body;
}
}
return key;
}
getGlobalEventTarget(target: string): EventTarget {
if (target == "window") {
return window;
} else if (target == "document") {
return document;
} else if (target == "body") {
return document.body;
}
}
getHistory() {
return window.history;
}
getLocation() {
return window.location;
}
getBaseHref() {
return relativePath(document.baseURI);
}
getUserAgent(): string {
return window.navigator.userAgent;
}
getHistory() { return window.history; }
getLocation() { return window.location; }
getBaseHref() { return relativePath(document.baseURI); }
getUserAgent(): string { return window.navigator.userAgent; }
}
// based on urlUtils.js in AngularJS 1

View File

@ -36,97 +36,96 @@ export class CssSelector {
if (isPresent(cssSel.notSelector) && isBlank(cssSel.element) &&
ListWrapper.isEmpty(cssSel.classNames) && ListWrapper.isEmpty(cssSel.attrs)) {
cssSel.element = "*";
} ListWrapper.push(res, cssSel);
}
var cssSelector = new CssSelector();
var matcher = RegExpWrapper.matcher(_SELECTOR_REGEXP, selector);
var match;
var current = cssSelector;
while (isPresent(match = RegExpMatcherWrapper.next(matcher))) {
if (isPresent(match[1])) {
if (isPresent(cssSelector.notSelector)) {
throw new BaseException('Nesting :not is not allowed in a selector');
}
current.notSelector = new CssSelector();
current = current.notSelector;
}
if (isPresent(match[2])) {
current.setElement(match[2]);
}
if (isPresent(match[3])) {
current.addClassName(match[3]);
}
if (isPresent(match[4])) {
current.addAttribute(match[4], match[5]);
}
if (isPresent(match[6])) {
_addResult(results, cssSelector);
cssSelector = current = new CssSelector();
}
}
_addResult(results, cssSelector);
return results;
}
constructor() {
this.element = null;
this.classNames = ListWrapper.create();
this.attrs = ListWrapper.create();
this.notSelector = null;
}
isElementSelector(): boolean {
return isPresent(this.element) && ListWrapper.isEmpty(this.classNames) &&
ListWrapper.isEmpty(this.attrs) && isBlank(this.notSelector);
}
setElement(element: string = null) {
if (isPresent(element)) {
element = element.toLowerCase();
}
this.element = element;
}
addAttribute(name: string, value: string = _EMPTY_ATTR_VALUE) {
ListWrapper.push(this.attrs, name.toLowerCase());
if (isPresent(value)) {
value = value.toLowerCase();
} else {
value = _EMPTY_ATTR_VALUE;
}
ListWrapper.push(this.attrs, value);
}
addClassName(name: string) {
ListWrapper.push(this.classNames, name.toLowerCase());
}
toString(): string {
var res = '';
if (isPresent(this.element)) {
res += this.element;
}
if (isPresent(this.classNames)) {
for (var i = 0; i < this.classNames.length; i++) {
res += '.' + this.classNames[i];
}
}
if (isPresent(this.attrs)) {
for (var i = 0; i < this.attrs.length;) {
var attrName = this.attrs[i++];
var attrValue = this.attrs[i++];
res += '[' + attrName;
if (attrValue.length > 0) {
res += '=' + attrValue;
ListWrapper.push(res, cssSel);
};
var cssSelector = new CssSelector();
var matcher = RegExpWrapper.matcher(_SELECTOR_REGEXP, selector);
var match;
var current = cssSelector;
while (isPresent(match = RegExpMatcherWrapper.next(matcher))) {
if (isPresent(match[1])) {
if (isPresent(cssSelector.notSelector)) {
throw new BaseException('Nesting :not is not allowed in a selector');
}
current.notSelector = new CssSelector();
current = current.notSelector;
}
if (isPresent(match[2])) {
current.setElement(match[2]);
}
if (isPresent(match[3])) {
current.addClassName(match[3]);
}
if (isPresent(match[4])) {
current.addAttribute(match[4], match[5]);
}
if (isPresent(match[6])) {
_addResult(results, cssSelector);
cssSelector = current = new CssSelector();
}
res += ']';
}
_addResult(results, cssSelector);
return results;
}
if (isPresent(this.notSelector)) {
res += ":not(" + this.notSelector.toString() + ")";
constructor() {
this.element = null;
this.classNames = ListWrapper.create();
this.attrs = ListWrapper.create();
this.notSelector = null;
}
isElementSelector(): boolean {
return isPresent(this.element) && ListWrapper.isEmpty(this.classNames) &&
ListWrapper.isEmpty(this.attrs) && isBlank(this.notSelector);
}
setElement(element: string = null) {
if (isPresent(element)) {
element = element.toLowerCase();
}
this.element = element;
}
addAttribute(name: string, value: string = _EMPTY_ATTR_VALUE) {
ListWrapper.push(this.attrs, name.toLowerCase());
if (isPresent(value)) {
value = value.toLowerCase();
} else {
value = _EMPTY_ATTR_VALUE;
}
ListWrapper.push(this.attrs, value);
}
addClassName(name: string) { ListWrapper.push(this.classNames, name.toLowerCase()); }
toString(): string {
var res = '';
if (isPresent(this.element)) {
res += this.element;
}
if (isPresent(this.classNames)) {
for (var i = 0; i < this.classNames.length; i++) {
res += '.' + this.classNames[i];
}
}
if (isPresent(this.attrs)) {
for (var i = 0; i < this.attrs.length;) {
var attrName = this.attrs[i++];
var attrValue = this.attrs[i++];
res += '[' + attrName;
if (attrValue.length > 0) {
res += '=' + attrValue;
}
res += ']';
}
}
if (isPresent(this.notSelector)) {
res += ":not(" + this.notSelector.toString() + ")";
}
return res;
}
return res;
}
}
/**

View File

@ -96,7 +96,11 @@ export class DomEventsPlugin extends EventManagerPlugin {
}
static sameElementCallback(element, handler, zone) {
return (event) => { if (event.target === element) { zone.run(() => handler(event)); } };
return (event) => {
if (event.target === element) {
zone.run(() => handler(event));
}
};
}
static bubbleCallback(element, handler, zone) {

View File

@ -89,20 +89,21 @@ export class KeyEventsPlugin extends EventManagerPlugin {
}
static eventCallback(element, shouldSupportBubble, fullKey, handler, zone) {
return (event) => { var correctElement = shouldSupportBubble || event.target === element;
if (correctElement && KeyEventsPlugin.getEventFullKey(event) === fullKey) {
zone.run(() => handler(event));
}
};
}
return (event) => {
var correctElement = shouldSupportBubble || event.target === element;
if (correctElement && KeyEventsPlugin.getEventFullKey(event) === fullKey) {
zone.run(() => handler(event));
}
};
}
static _normalizeKey(keyName: string): string {
// TODO: switch to a StringMap if the mapping grows too much
switch (keyName) {
case 'esc':
return 'escape';
default:
return keyName;
static _normalizeKey(keyName: string): string {
// TODO: switch to a StringMap if the mapping grows too much
switch (keyName) {
case 'esc':
return 'escape';
default:
return keyName;
}
}
}
}

View File

@ -331,31 +331,33 @@ export class SpyObject {
}
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 (n instanceof Array) {
return n.map((nn) => elementText(nn)).join("");
}
if (n instanceof Array) {
return n.map((nn) => elementText(nn)).join("");
}
if (DOM.isCommentNode(n)) {
return '';
}
if (DOM.isCommentNode(n)) {
return '';
}
if (DOM.isElementNode(n) && DOM.tagName(n) == 'CONTENT') {
return elementText(Array.prototype.slice.apply(DOM.getDistributedNodes(n)));
}
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 (DOM.hasShadowRoot(n)) {
return elementText(DOM.childNodesAsList(DOM.getShadowRoot(n)));
}
if (hasNodes(n)) {
return elementText(DOM.childNodesAsList(n));
}
if (hasNodes(n)) {
return elementText(DOM.childNodesAsList(n));
}
return DOM.getText(n);
return DOM.getText(n);
}
export function isInInnerZone(): boolean {

View File

@ -13,12 +13,10 @@ export class Log {
fn(value) {
return (a1 = null, a2 = null, a3 = null, a4 = null, a5 = null) => {
ListWrapper.push(this._result, value);
}
}
}
result(): string {
return ListWrapper.join(this._result, "; ");
}
result(): string { return ListWrapper.join(this._result, "; "); }
}
export function viewRootNodes(view): List</*node*/ any> {

View File

@ -227,7 +227,7 @@ export function main() {
return [bind(ChangeDetection)
.toFactory(() => new DynamicChangeDetection(
new PipeRegistry({"double": [new DoublePipeFactory()]})),
[])];
[])];
});
it("should support pipes in bindings and bind config",

View File

@ -3934,7 +3934,7 @@
}
},
"gulp-clang-format": {
"version": "1.0.12",
"version": "1.0.13",
"dependencies": {
"gulp-util": {
"version": "3.0.4",
@ -4112,7 +4112,7 @@
}
},
"clang-format": {
"version": "1.0.12"
"version": "1.0.14"
}
}
},

12
npm-shrinkwrap.json generated
View File

@ -6073,9 +6073,9 @@
}
},
"gulp-clang-format": {
"version": "1.0.12",
"from": "https://registry.npmjs.org/gulp-clang-format/-/gulp-clang-format-1.0.12.tgz",
"resolved": "https://registry.npmjs.org/gulp-clang-format/-/gulp-clang-format-1.0.12.tgz",
"version": "1.0.13",
"from": "https://registry.npmjs.org/gulp-clang-format/-/gulp-clang-format-1.0.13.tgz",
"resolved": "https://registry.npmjs.org/gulp-clang-format/-/gulp-clang-format-1.0.13.tgz",
"dependencies": {
"gulp-util": {
"version": "3.0.4",
@ -6351,9 +6351,9 @@
}
},
"clang-format": {
"version": "1.0.12",
"from": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.12.tgz",
"resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.12.tgz"
"version": "1.0.14",
"from": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.14.tgz",
"resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.14.tgz"
}
}
},

View File

@ -64,7 +64,7 @@
"gulp": "^3.8.8",
"gulp-autoprefixer": "^2.1.0",
"gulp-changed": "^1.0.0",
"gulp-clang-format": "^1.0.12",
"gulp-clang-format": "^1.0.13",
"gulp-concat": "^2.5.2",
"gulp-connect": "~1.0.5",
"gulp-load-plugins": "^0.7.1",