Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep respective order of `javascript:` loads and other scripts #4261

Closed
ebruchez opened this issue Nov 6, 2019 · 3 comments
Closed

Keep respective order of `javascript:` loads and other scripts #4261

ebruchez opened this issue Nov 6, 2019 · 3 comments

Comments

@ebruchez
Copy link
Collaborator

@ebruchez ebruchez commented Nov 6, 2019

Following #4195, we moved loads that are not javascript: to the end. However, we do not keep the order of invocations between javascript: loads and other script invocations.

Here, we have the following scenario:

  • value changes in field
  • user presses button
  • associated process
    • saves data
    • marks it as "safe", which toggles "data safe" status by scheduling client-side script
    • calls JavaScript with navigate and a javascript: URL
  • server sends to the client
    • xxf:load
    • then xxf:script

This causes the order of execution to be different on the client.

<xxf:event-response xmlns:xxf="http://orbeon.org/oxf/xml/xforms">
    <xxf:action>
        <xxf:control-values>
            <xxf:control id="xf-292" relevant="false"/>
            <xxf:control id="xf-293" relevant="false"/>
            <xxf:attribute for="xf-294" name="title"/>
            <xxf:control id="section-1-section≡xf-537" visited="true"/>
            <xxf:control id="section-1-section≡grid-1-grid≡xf-554" visited="true"/>
        </xxf:control-values>
        <xxf:repeat-indexes>
            <xxf:repeat-index id="xf-284" new-index="0"/>
            <xxf:repeat-index id="xf-344" new-index="4"/>
        </xxf:repeat-indexes>
        <xxf:load resource="javascript:foo()" show="replace" show-progress="false"/>
        <xxf:script name="xf_fe2cdd47e080e5004ca9a0f9cc06180236b7734f" target-id="xf-351" observer-id="fr-view">
            <xxf:param>true</xxf:param>
        </xxf:script>
    </xxf:action>
</xxf:event-response>

+1 from customer

@ebruchez ebruchez self-assigned this Nov 6, 2019
@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

@ebruchez ebruchez commented Nov 6, 2019

Possible solution:

  • addLoadToRun for javascript: and addScriptToRun keep their order
  • works for Ajax responses
  • check comment "NOTE: The order of script actions vs. javascript: loads should be preserved. It is not currently."
  • works for initial loads for master branch
    • TODO
  • backport to 2018.1 for customer
  • check change for #3565 in XFormsContainingDocument
@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

@ebruchez ebruchez commented Nov 7, 2019

Unfortunately, addressing this problem doesn't solve the original issue, because the process schedules the javascript: load before the script action runs. And that is because the script action runs upon xforms-value-changed, which happens during a subsequent refresh.

@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

@ebruchez ebruchez commented Nov 7, 2019

This can be solved by making the xf:load action, used for navigate, synchronize everything before running, like other actions.

@ebruchez ebruchez closed this in 2cce5f0 Nov 7, 2019
ebruchez added a commit that referenced this issue Nov 7, 2019
ebruchez added a commit that referenced this issue Nov 7, 2019
@ebruchez ebruchez added this to In progress in Orbeon Forms 2019.2 Nov 8, 2019
@ebruchez ebruchez moved this from In progress to Done in Orbeon Forms 2019.2 Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
1 participant
You can’t perform that action at this time.