WYSIWYG field #1025

Closed
Jaromudr opened this Issue Mar 25, 2013 · 3 comments

Comments

Projects
None yet
3 participants

Hi

In my project I use CKE Editor for email field.
I have validation for it. I am checking if there is "install link" in email.

When I create cucumber test, I get unexpected result, when I send this form to server I can see that capybara cuts tags from textarea.

In file
lib/capybara/rack_test/form.rb I found next code:

18    def params(button)
...
56      when 'textarea'
57       merge_param!(params, field['name'].to_s, field.text.to_s)
58      end

As I understood field.text cuts all tags. It is posible to use field.inner_html instead, but I did not know if it will influence smth else.

So, can you suggest elegant way to fix this behaviour?

@jnicklas jnicklas closed this in ca4781f Mar 26, 2013

Collaborator

jnicklas commented Mar 26, 2013

There does indeed seem to be an issue when HTML is already contained within a textarea when the page is loaded. If the textarea is filled in via fill_in or set, everything works as intended. However there was some weird encoding/decoding going on, which doesn't seem to be necessary. Using inner_html everywhere as opposed to text/content seems to work better.

jnicklas added a commit that referenced this issue Mar 27, 2013

Revert "Return html inside textareas when page is loaded. Closes #1025"
It seems like textareas must not contain HTML content according to the
HTML spec.

This reverts commit ca4781f.

Conflicts:
	lib/capybara/spec/session/node_spec.rb
Collaborator

jnicklas commented Mar 27, 2013

Just revisited this, and it seems that according to the HTML5 spec, textareas must not contain literal HTML. It seems that browsers support this anyway, to a certain extent at least, but it does not seem to be wellformed markup. I've reverted the change I made originally, since it does not seem to be in conformance with the spec.

So problem is little deeper, I tested my example on Chromium browser and I got next results

document.getElementById("share_template").innerText =>

<div class='top' style="margin: 0;  padding: 0;  font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; min-height: 65px;  padding: 10px;  border-bottom: 1px solid #c9c9c9;">
<img alt="Icon"  ....

document.getElementById("share_template").innerHTML =>

"&lt;div class='top' style="margin: 0;  padding: 0;  font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; min-height: 65px;  padding: 10px;  border-bottom: 1px solid #c9c9c9;"&gt;
&lt;img alt="Icon"

So, textarea do not contain literal HTML, it contain html escaped string.

With capybara I got next results

field.inner_text => "\n\n\n\nCLM Tool\n\n\n1.0\n\n\n ..."

field.inner_html =>

<div class=\"top\" style=\"margin: 0;  padding: 0;  font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; min-height: 65px;  padding: 10px;  border-bottom: 1px solid #c9c9c9;\">\n<img alt=\"Icon\"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment