rails/actionview/app
Raymond Zhou 48e44edfd0 Pass HTML responses as plain-text in rails-ujs
Running HTML responses through `DOMParser#parseFromString` results in
complete `HTMLDocument` instances with unnecessary surrounding tags.

For example:

    new DOMParser().parseFromString('<p>hello</p>', 'text/html')

Will output:

    <html>
      <head></head>
      <body>
        <p>hello</p>
      </body>
    </html>

This is passed to the `ajax:success` handler as `event.detail[0]`
(`data`), but cannot be used directly without first traversing the
document.

To resolve this, only XML content is passed through `parseFromString`,
while HTML content is treated as plain-text.

This matches the behavior of jquery-ujs, which relied on jQuery's
response-type inference.
2018-03-19 03:24:56 -04:00
..
assets/javascripts Pass HTML responses as plain-text in rails-ujs 2018-03-19 03:24:56 -04:00