rails/actionview
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
..
app/assets/javascripts Pass HTML responses as plain-text in rails-ujs 2018-03-19 03:24:56 -04:00
bin Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
lib Pass the skip_pipeline option in image_submit_tag 2018-03-14 11:18:06 +00:00
test Pass HTML responses as plain-text in rails-ujs 2018-03-19 03:24:56 -04:00
.gitignore Clean up and consolidate .gitignores 2018-02-17 14:26:19 -08:00
actionview.gemspec Rails 6 requires Ruby 2.4.1+ 2018-02-17 15:34:57 -08:00
blade.yml Add rails-ujs to Action View 2016-11-26 01:23:07 -05:00
CHANGELOG.md Remove changelog header for unreleased version 2018-03-13 15:20:57 -04:00
coffeelint.json Test rails-ujs in our travis matrix 2017-02-22 13:49:28 -05:00
MIT-LICENSE Bump license years for 2018 2017-12-31 22:36:55 +09:00
package.json Start Rails 6.0 development!!! 2018-01-30 18:51:17 -05:00
Rakefile Correctly kill the server started with ujs test 2017-11-09 11:34:05 +09:00
README.rdoc Fix typos and add a few suggestions 2017-11-28 19:27:43 +01:00
RUNNING_UJS_TESTS.rdoc Fix typos and add a few suggestions 2017-11-28 19:27:43 +01:00
RUNNING_UNIT_TESTS.rdoc Fix typos and add a few suggestions 2017-11-28 19:27:43 +01:00

= Action View

Action View is a framework for handling view template lookup and rendering, and provides
view helpers that assist when building HTML forms, Atom feeds and more.
Template formats that Action View handles are ERB (embedded Ruby, typically
used to inline short Ruby snippets inside HTML), and XML Builder.

== Download and installation

The latest version of Action View can be installed with RubyGems:

  $ gem install actionview

Source code can be downloaded as part of the Rails project on GitHub:

* https://github.com/rails/rails/tree/master/actionview


== License

Action View is released under the MIT license:

* https://opensource.org/licenses/MIT


== Support

API documentation is at

* http://api.rubyonrails.org

Bug reports for the Ruby on Rails project can be filed here:

* https://github.com/rails/rails/issues

Feature requests should be discussed on the rails-core mailing list here:

* https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core