diff --git a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js
index 91bfbf6330..4fe687ffd1 100644
--- a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js
+++ b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js
@@ -63,6 +63,8 @@ module.exports = function autoLinkCode(getDocFromAlias) {
const nodes = getNodes(node, file);
// Replace the text node with the links and leftover text nodes
Array.prototype.splice.apply(parent.children, [index, 1].concat(nodes));
+ // Do not visit this node's children or the newly added nodes
+ return [visit.SKIP, index + nodes.length];
}
});
});
diff --git a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js
index 6cd68bbd7a..cfd58ca55c 100644
--- a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js
+++ b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js
@@ -110,11 +110,32 @@ describe('autoLinkCode post-processor', () => {
'{ xyz | myClass } ' +
'{ xyz|myClass } ' +
'MyClass ' +
- 'myClass ' +
+ 'myClass ' +
'OtherClass|MyClass' +
'');
});
+ it('should ignore generated nodes', () => {
+ const filterAnchors = (docs, words, index) => (words[index].toLowerCase() === 'a') ? [] : docs;
+ autoLinkCode.customFilters = [filterAnchors];
+ autoLinkCode.docTypes = ['directive'];
+
+ aliasMap.addDoc({
+ docType: 'directive',
+ id: 'MyAnchorDirective',
+ aliases: ['MyAnchorDirective', 'a'],
+ path: 'a/b/my-anchor-directive',
+ });
+ const doc = {
+ docType: 'test-doc',
+ renderedContent: '<a>
',
+ };
+
+ processor.$process([doc]);
+
+ expect(doc.renderedContent).toBe('<a>
');
+ });
+
it('should ignore code items that match an internal API doc', () => {
aliasMap.addDoc({
docType: 'class',