[
https://issues.apache.org/jira/browse/WICKET-7177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18066134#comment-18066134
]
ASF GitHub Bot commented on WICKET-7177:
----------------------------------------
jstuyts commented on PR #1385:
URL: https://github.com/apache/wicket/pull/1385#issuecomment-4069048113
@kbachl Yes, jQuery does not support XML, so a different way of replacing
markup is needed.
I do not mind removing jQuery, but that seems like a much larger change for
supporting a very narrow use case. Also, the replacement of jQuery must be 100%
compatible. If developers are already sending SVG or MathML (possibly
surrounded by HTML) in their responses, a replacement must not change the
semantics. So even with a jQuery replacement, alternative replacement methods
will still be needed.
Side note: I first tried [Preact](https://preactjs.com/) because this would
also give more efficient DOM updates, but ran into 2 problems:
* Because elements are not replaced but updated, listeners were registered
multiple times.
* I could not get XML replacement to work reliably.
This implementation was also chosen because I want to be able to mix
existing (third-party) Ajax code with replacement-method aware code. Both get
the same `AjaxRequestTarget` and can use it without interfering with each other.
The logic for replacing markup is:
* Use the default jQuery method if no replacement method is specified. This
ensures all current code behaves the same.
* Use a registered replacement method if one is registered for the
identifier.
* Throw an error if an identifier in the response does not have a
replacement method registered for it.
The changes can only be used if you are aware they are there. Existing
JavaScript that calls Wicket directly will continue to work, and will see the
current behavior.
> Allow alternative replacement methods to support Ajax for SVG and MathML
> ------------------------------------------------------------------------
>
> Key: WICKET-7177
> URL: https://issues.apache.org/jira/browse/WICKET-7177
> Project: Wicket
> Issue Type: Improvement
> Reporter: Johan Stuyts
> Priority: Major
> Labels: ajax, mathml, svg, websocket, xml
>
> jQuery is used to replace markup in Ajax (and WebSocket) requests. But jQuery
> does not support replacing XML, so dynamically updating (a part of) an
> embedded SVG or MathML formula is not possible.
> This will add the possibility to use alternative replacement methods for
> partial markup replacement. Using an alternative replacement method consists
> of 2 steps:
> * Register the replacement method in the user agent.
> * In partial page updates specify with which replacement method the markup
> of a component must be replaced.
> The user is in full control: which replacement method to use can be specified
> per component.
> Initially only a replacement method for XML is provided. This can be used to
> update (parts of) SVGs and MathML formulas. Note that full compatibility and
> feature parity with the standard jQuery replacement method is not a goal. It
> is also not a full-blown SVG or MathML library, but is required to be able to
> build one.
> The changes are fully backward compatible with existing Wicket code. There is
> a tiny runtime impact on both the server and client side, as checks for the
> presence of replacement method properties/attributes must be made.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)