mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-76694 core_comment: exit the js init if the element cannot be found
In pages which result in the theme_boost/embedded template being used, blocks may be rendered and the resulting HTML ignored, leaving any JS they may have added to run without a corresponding DOM element to act on. This fixes that case for comments, making sure we exit gracefully during the init if the element can't be found.
This commit is contained in:
parent
769c67045f
commit
832e394322
@ -41,6 +41,11 @@ M.core_comment = {
|
||||
this.courseid = args.courseid;
|
||||
this.contextid = args.contextid;
|
||||
this.autostart = (args.autostart);
|
||||
// Fail fast if the comments element cannot be found, such as in embedded-type views where blocks may be loaded
|
||||
// then discarded.
|
||||
if (!Y.one('#comment-ctrl-'+this.client_id)) {
|
||||
return;
|
||||
}
|
||||
// expand comments?
|
||||
if (this.autostart) {
|
||||
this.view(args.page);
|
||||
|
Loading…
x
Reference in New Issue
Block a user