MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / addParent

Function addParent

packages/core/css/lib/parse/index.ts:567–592  ·  view source on GitHub ↗

* Adds non-enumerable parent node reference to each node.

(obj, parent?)

Source from the content-addressed store, hash-verified

565 */
566
567function addParent(obj, parent?) {
568 var isNode = obj && typeof obj.type === 'string';
569 var childParent = isNode ? obj : parent;
570
571 for (var k in obj) {
572 var value = obj[k];
573 if (Array.isArray(value)) {
574 value.forEach(function (v) {
575 addParent(v, childParent);
576 });
577 } else if (value && typeof value === 'object') {
578 addParent(value, childParent);
579 }
580 }
581
582 if (isNode) {
583 Object.defineProperty(obj, 'parent', {
584 configurable: true,
585 writable: true,
586 enumerable: false,
587 value: parent || null,
588 });
589 }
590
591 return obj;
592}

Callers 1

parseFunction · 0.85

Calls 1

forEachMethod · 0.80

Tested by

no test coverage detected