Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-63763

Javascript fails to load in certain situations

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6
    • Fix Version/s: 3.6
    • Component/s: JavaScript
    • Labels:
    • Testing Instructions:
      Hide
      1. Setup: Disable admin setting cachejs
      2. Using chrome browser, go to the login page and open dev tools. 
      3. On the sources tab select the first.js file.
      4. search for the string "define('core/sortable_list'" in first.js
        1. Confirm that it exists in one place only
           

       

      Show
      Setup: Disable admin setting cachejs Using chrome browser, go to the login page and open dev tools.  On the sources tab select the first.js file. search for the string "define('core/sortable_list'" in first.js Confirm that it exists in one place only    
    • Affected Branches:
      MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_36_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-63763-master

      Description

      When "cache javascript" is turned off, Moodle's requirejs.php does not correctly process AMD js files which include usage examples including the text "define(" in comments ahead of the "define(" line.

      This results in first.js being incorrectly built to include anonymous defines, and a variety of possible errors, which may appear intermittently. In my case I either had jquery-ui fail to load, or a "mismatched anonymous define" error from require.js, depending on timing.

      Either requirejs.php needs to strip comments before processing, or it needs to be documented that AMD modules MUST NOT include the text "define(", even in comments, before the actual module define text.

      Currently this only appears to apply to sortable_list.js in core, but it also applies to mod_bootstrapelements/amd/src/instance.js causes and potentially other plugins.

      As this is extremely time-consuming to debug, I'd suggest it is important that it be fixed for 3.6, probably best by documentation and the inclusion of a space between "define" and "(" in sortable_list.js comments.

      In the long term, requirejs.php needs to be fixed.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  3/Dec/18

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 10 minutes
                  10m