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

Improve the fragments API



    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.1
    • Component/s: JavaScript
    • Labels:


      There are some problems, and inflexible bits of the new fragments javascript API.

      1. It does not notify the filters about inserted content
      2. It does not return a promise so there is no way to chain actions after the fragment is loaded
      3. It does not allow any control over how the dom nodes are injected (fade in etc)
      4. It is not using the safe YUI instance from core/yui
      5. The javascriptnodeidentifier argument is unnessesary
      6. It does not need to remove event listeners from script nodes.
      7. It does not pass the context to the callback so it can be verified.
      8. The arguments are passed from javascript as a named array - but through php as a flat array which means the order is undetermined.

      A better API would be to change fragmentAppend to loadFragment which returns a promise. The promise will be resolved with the html and js variables and the caller is responsible for adding them to the page. They can re-use the templates.replaceNodeContents function to add the nodes - which will correctly notify the filters etc.

      There is some code in there to cleanup YUI event listeners - I'll check the YUI source to see if that is truely needed - and if so - we can add it to the templates.replaceNode and templates.replaceNodeContents functions.


          Issue Links



              • Votes:
                0 Vote for this issue
                8 Start watching this issue


                • Created:
                  Fix Release Date: