MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 853: Line 853:
                 if (!alreadyTagged) { translatableSpans = []; tagTextNodes(); }
                 if (!alreadyTagged) { translatableSpans = []; tagTextNodes(); }
                 else {
                 else {
                     document.querySelectorAll('.vector-toc .vector-toc-text:not([data-deva])').forEach(function (span) {
                     // tagTocEntry, not a re-tag from textContent: an entry
                        var orig = span.textContent; if (!orig.trim()) return;
                    // keeps its Devanagari in a span *inside* .vector-toc-text,
                        span.setAttribute('data-deva', orig); translatableSpans.push(span);
                    // so .vector-toc-text itself never carries data-deva and a
                    });
                    // :not([data-deva]) sweep matched every entry on every
                    // fire. It then stored the text as it stood — Tamil, once
                    // the reader had switched — as that entry's "original", so
                    // the next switch had no Devanagari left to work from and
                    // the contents panel stayed in the previous script while
                    // the body moved on. tagTocEntry leaves a tagged entry be.
                    document.querySelectorAll('.vector-toc .vector-toc-text').forEach(tagTocEntry);
                 }
                 }
                 if (currentScript !== 'deva') applyScript(currentScript);
                 if (currentScript !== 'deva') applyScript(currentScript);