Add a property "talkNsText" to mw.title objects

Bug: T180911
Change-Id: I847ac4b7587b98be06b25fe14765e9efdc7b774d
This commit is contained in:
vlakoff 2017-11-19 16:22:03 +00:00 committed by jenkins-bot
parent d75dd9fc0c
commit e1bd4911bd
2 changed files with 17 additions and 1 deletions

View file

@ -64,7 +64,15 @@ local function makeTitleObject( data )
data.isSpecialPage = data.namespace == mw.site.namespaces.Special.id
data.isTalkPage = ns.isTalk
data.subjectNsText = ns.subject.name
data.canTalk = ns.talk ~= nil
if ns.talk ~= nil then
data.canTalk = true
if not data.isExternal then
data.talkNsText = ns.talk.name
end
else
data.canTalk = false
end
data.prefixedText = data.text
if data.nsText ~= '' then

View file

@ -266,6 +266,14 @@ local tests = {
args = { 'subjectNsText' },
expect = { '', 'Module', '', '', '', 'Module', 'Module' }
},
{ name = '.canTalk', func = prop_foreach,
args = { 'canTalk' },
expect = { true, true, true, true, true, true, true }
},
{ name = '.talkNsText', func = prop_foreach,
args = { 'talkNsText' },
expect = { 'Talk', 'Module talk', nil, 'Talk', 'Talk', 'Module talk', 'Module talk' }
},
{ name = '.fragment', func = prop_foreach,
args = { 'fragment' },
expect = { '', '', '', 'frag', '', ' frag frag', ' frag frag' }