mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Making tslint happy.
This commit is contained in:
@ -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
2
ui/core/view.d.ts
vendored
@ -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.
|
||||||
|
Reference in New Issue
Block a user