Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-122450

As a Developer I want an way to evaluate asynchronously loaded scripts

    Details

    • Type: Story
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects Version/s: None
    • Fix Version/s: Master
    • Labels:
      None

      Description

      One common workflow in highly interactive apps is asynchronously fetching external markup and then injecting it in a page. We used this technique in many places to dynamically update panel contents or preview fragments...

      One problem with this technique is that any JavaScript contained in the response is not executed when added via the standard appendChild API.

      To account for it, different libraries offer different solutions like:

      The goal of this story is to provide a custom globalEval that can be used throughout DXP as a replacement of the mentioned direct use cases.

      Acceptance Criteria

      • A runScriptsInElement method (or other name) is exported from frontend-js-web that allows to pass
        • element The DOM element whose scripts should be executed
      • The method is unit tested and documented

      Additional Considerations
      The current implementation of runScriptsInElement also accepts defaultFn and appendFn. While those can be useful, we don't have real usages for it in DXP so we can probably simplify the API design for now.

        Attachments

          Activity

            People

            Assignee:
            bryce.osterhaus Bryce Osterhaus
            Reporter:
            jose.balsas Chema Balsas
            Engineering Assignee:
            Bryce Osterhaus
            Recent user:
            Kiyoshi Lee
            Participants of an Issue:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Packages

                Version Package
                Master