MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / getParentView

Method getParentView

packages/core/ui/core/bindable/index.ts:554–586  ·  view source on GitHub ↗
(target: any, property: string)

Source from the content-addressed store, hash-verified

552 }
553
554 private getParentView(target: any, property: string): { view: ViewBase; index: number } {
555 if (!target) {
556 return { view: null, index: null };
557 }
558
559 let result: ViewBase;
560 if (property === bc.parentValueKey) {
561 result = target.parent;
562 }
563
564 let index = null;
565 if (property.indexOf(bc.parentsValueKey) === 0) {
566 result = target.parent;
567 const indexParams = paramsRegex.exec(property);
568 if (indexParams && indexParams.length > 1) {
569 index = indexParams[2];
570 }
571
572 if (!isNaN(index)) {
573 let indexAsInt = parseInt(index);
574 while (indexAsInt > 0) {
575 result = result.parent;
576 indexAsInt--;
577 }
578 } else if (types.isString(index)) {
579 while (result && result.typeName !== index) {
580 result = result.parent;
581 }
582 }
583 }
584
585 return { view: result, index: index };
586 }
587
588 private resolveOptions(obj: Object, properties: Array<string>): { instance: WeakRef<Object>; property: any } {
589 const objectsAndProperties = this.resolveObjectsAndProperties(obj, properties);

Callers 2

Calls 1

indexOfMethod · 0.80

Tested by

no test coverage detected