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

Javascript fails to load in certain situations

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.6
    • 3.6
    • JavaScript
    • MOODLE_36_STABLE
    • MOODLE_36_STABLE
    • MDL-63763-master
    • 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    

    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

              nwpotago Nick Phillips
              nwpotago Nick Phillips
              Damyon Wiese Damyon Wiese
              Andrew Lyons Andrew Lyons
              Janelle Barcega Janelle Barcega
              Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                3/Dec/18

                Time Tracking

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