diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 94b3e37a4..e1821e108 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -571,8 +571,11 @@ exports.extractTranscludes = function(parseTreeRoot, title) { } else if(parseTreeNode.attributes.tiddler && parseTreeNode.attributes.tiddler.type === "string") { value = parseTreeNode.attributes.tiddler.value; } - // ignore empty value (like `{{!!field}}`), and deduplicate - if(value && transcludes.indexOf(value) === -1 && value !== title) { + if (!value) { + value = title; + } + // Empty value (like `{{!!field}}`) means self-referential transclusion. Also deduplicate the result. + if(transcludes.indexOf(value) === -1) { transcludes.push(value); } } diff --git a/editions/test/tiddlers/tests/test-backtranscludes.js b/editions/test/tiddlers/tests/test-backtranscludes.js index d9aa0277f..bae0e83ee 100644 --- a/editions/test/tiddlers/tests/test-backtranscludes.js +++ b/editions/test/tiddlers/tests/test-backtranscludes.js @@ -182,7 +182,7 @@ describe('Backtranscludes and transclude filter tests', function() { }); }); - describe('ignore self transclusion', function() { + describe('include implicit self transclusion', function() { var wiki = new $tw.Wiki(); wiki.addTiddler({ @@ -190,15 +190,15 @@ describe('Backtranscludes and transclude filter tests', function() { text: "{{!!created}}\n\nAn implicit self-referential transclude to <$transclude $field='created'/> and <$transclude field='created'/>"}); it('should have no transclude', function() { - expect(wiki.filterTiddlers('TestOutgoing +[transcludes[]]').join(',')).toBe(''); + expect(wiki.filterTiddlers('TestOutgoing +[transcludes[]]').join(',')).toBe('TestOutgoing'); }); it('should have no back transcludes', function() { - expect(wiki.filterTiddlers('TestOutgoing +[backtranscludes[]]').join(',')).toBe(''); + expect(wiki.filterTiddlers('TestOutgoing +[backtranscludes[]]').join(',')).toBe('TestOutgoing'); }); }); - describe('Explicit self transclusion', function() { + describe('include explicit self transclusion', function() { var wiki = new $tw.Wiki(); wiki.addTiddler({ @@ -206,15 +206,15 @@ describe('Backtranscludes and transclude filter tests', function() { text: "{{TestOutgoing!!created}}\n\n<$transclude $tiddler='TestOutgoing' $field='created'/> and <$transclude tiddler='TestOutgoing' field='created'/>"}); it('should have no transclude', function() { - expect(wiki.filterTiddlers('TestOutgoing +[transcludes[]]').join(',')).toBe(''); + expect(wiki.filterTiddlers('TestOutgoing +[transcludes[]]').join(',')).toBe('TestOutgoing'); }); it('should have no back transcludes', function() { - expect(wiki.filterTiddlers('TestOutgoing +[backtranscludes[]]').join(',')).toBe(''); + expect(wiki.filterTiddlers('TestOutgoing +[backtranscludes[]]').join(',')).toBe('TestOutgoing'); }); }); - describe('recognize soft transclusion defined by widget', function() { + describe('recognize transclusion defined by widget', function() { var wiki = new $tw.Wiki(); wiki.addTiddler({