Making tslint happy.

This commit is contained in:
Hristo Deshev
2015-08-07 10:45:42 +03:00
parent c5608d7c5c
commit a526e6cec8
2 changed files with 8 additions and 5 deletions

View File

@ -57,14 +57,16 @@ export function eachDescendant(view: definition.View, callback: (child: View) =>
export function getAncestor(view: View, criterion: string | Function): definition.View { export function getAncestor(view: View, criterion: string | Function): definition.View {
let matcher: (view: definition.View) => boolean = null; let matcher: (view: definition.View) => boolean = null;
if (typeof criterion === "string") if (typeof criterion === "string") {
matcher = (view: definition.View) => view.typeName === criterion; matcher = (view: definition.View) => view.typeName === criterion;
else } else {
matcher = (view: definition.View) => view instanceof criterion; matcher = (view: definition.View) => view instanceof criterion;
}
for (let parent: definition.View = view.parent; parent != null; parent = parent.parent) { for (let parent: definition.View = view.parent; parent != null; parent = parent.parent) {
if (matcher(parent)) if (matcher(parent)) {
return parent; return parent;
}
} }
return null; return null;
@ -337,8 +339,9 @@ export class View extends proxy.ProxyObject implements definition.View {
} }
get page(): definition.View { get page(): definition.View {
if (this.parent) if (this.parent) {
return this.parent.page; return this.parent.page;
}
return null; return null;
} }

2
ui/core/view.d.ts vendored
View File

@ -22,7 +22,7 @@ declare module "ui/core/view" {
*/ */
export function eachDescendant(view: View, callback: (child: View) => boolean); export function eachDescendant(view: View, callback: (child: View) => boolean);
/** /**
* Gets an ancestor from a given type. * Gets an ancestor from a given type.
* @param view - Starting view (child view). * @param view - Starting view (child view).
* @param criterion - The type of ancestor view we are looking for. Could be a string containing a class name or an actual type. * @param criterion - The type of ancestor view we are looking for. Could be a string containing a class name or an actual type.