message.js and action.js load order causes error

mattrogowski

Well-known member
Affected version
2.3.4
Not sure how much can actually be done about this but it seems to be a regression with the 2.3 javascript rewrite.

If templates include message.js and action.js in that specific order, a javascript error seems to be thrown:

core.js?_v=fe468900:3971 Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')

fn.prototype = Object.create(parent.prototype)

This causes things like replies to load in a modal when you submit a reply to a thread.

Usually action.js may well be included before message.js, and indeed it is in thread_view for example, but if an addon makes a template modification that includes message.js before action.js has been included, it will be loaded first in the page markup and the error will be thrown on page load.

It is fixed if instead action.js is loaded before message.js, like this:

<xf:js src="xf/action.js,xf/message.js" min="1" />

This seems to be a regression though on the basis that this never seemed to be an issue before, because previously just <xf:js src="xf/message.js" min="1" /> would work and action.js would just be included later on somewhere if needed and it worked fine.

However, it seems that message.js now has a direct dependency on action.js, and I'm having to add action.js to every place message.js is included. This doesn't seem either intentional or optimal.

I've encountered this issue a few times now when upgrading addons for 2.3. If action.js should be included every time message.js is included, it probably needs to automatically inject it first as a dependency or be sorted as required in the list of loaded javascript files.
 
Last edited:
Can confirm I'm having this same error having upgraded to 2.3, even with addons that are otherwise 2.3 compatible. Upgrading otherwise is going fine besides this.
 
Back
Top Bottom