| 577 | } |
| 578 | |
| 579 | function addChild(currentNode, childNode, matcher, startIndex) { |
| 580 | // unset startIndex if not requested |
| 581 | if (!this.options.captureMetaData) startIndex = undefined; |
| 582 | |
| 583 | // Pass jPath string or matcher based on options.jPath setting |
| 584 | const jPathOrMatcher = this.options.jPath ? matcher.toString() : matcher; |
| 585 | const result = this.options.updateTag(childNode.tagname, jPathOrMatcher, childNode[":@"]) |
| 586 | if (result === false) { |
| 587 | //do nothing |
| 588 | } else if (typeof result === "string") { |
| 589 | childNode.tagname = result |
| 590 | currentNode.addChild(childNode, startIndex); |
| 591 | } else { |
| 592 | currentNode.addChild(childNode, startIndex); |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | /** |
| 597 | * @param {object} val - Entity object with regex and val properties |