Download & Extend

Change default Ajax insertion method from replaceWith to html

Project:Drupal core
Version:8.x-dev
Component:ajax system
Category:task
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Currently, if neither #ajax['method'] nor a 'method' property on an Insert command returned by an Ajax response are explicitly set, the default method used is replaceWith which replaces the wrapper. Should we change this to html, so as not to replace the wrapper?

Next steps would be to add comments to this issue with pros/cons of wrapper replacement.

Comments

#1

Yes we should. Key reason: The wrapper may have all kinds of classes or IDs or data-* or RDF attributes on it that I don't know or care about for ajax purposes. I shouldn't have to figure them out and replicate them just to replace the wrapper with what is already there.

Potential downside: we'd need to ensure that the text we're replacing doesn't have the wrapper in it. Like most things in Drupal I suspect we're horribly inconsistent on this front.

nobody click here