Page MenuHomePhabricator

JS errors in MobileFrontend in Main Pages of some Wikimedia sites with $container = null in createBanner in cleanuptemplates.js
Closed, DuplicatePublic

Description

To reproduce:

Observed:

cleanuptemplates.js?4ad4e:54 Uncaught TypeError: Cannot read property 'find' of null
    at createBanner (cleanuptemplates.js?4ad4e:54)
    at initPageIssues (cleanuptemplates.js?4ad4e:104)
    at cleanuptemplates.js?4ad4e:117
    at cleanuptemplates.js?4ad4e:118
    at cleanuptemplates.js?4ad4e:120
createBanner @ cleanuptemplates.js?4ad4e:54
initPageIssues @ cleanuptemplates.js?4ad4e:104
(anonymous) @ cleanuptemplates.js?4ad4e:117
(anonymous) @ cleanuptemplates.js?4ad4e:118
(anonymous) @ cleanuptemplates.js?4ad4e:120

This happens in this code in cleanuptemplates.js:

		function createBanner( $container, labelText, headingText ) {
			var selector = 'table.ambox, table.tmbox, table.cmbox',
				$metadata = $container.find( selector ), // <----- HERE
				issues = [],
				$link;

This happens consistently:

  • in Chrome and Firefox
  • logged-in and logged-out
  • with debug=true and without it
  • in English and Hebrew Wikipedias, but only on the Main Page. I couldn't consistently reproduce it in the German Wikipedia or in English Wikipedia articles other than the Main Page.

Event Timeline

TheDJ subscribed.

$container = ns === 14 ? $( '#bodyContent' ) :
M.getCurrentPage().getLeadSectionElement();
createBanner( $container, etc.....

So if it probably fails to find the lead section, and this will likely be null (should probably be empty jquery collection instead) and this null value is then passed to createBanner.