Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8010 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Element.replace now properly replaces form elements in Firefox

Reported by: cainlevy Assigned to: Tobie
Priority: normal Milestone: 1.x
Component: Prototype Version: 1.2.3
Severity: normal Keywords: 1.5.2 ready
Cc:

Description

Element.replace fails to replace a <form> element with another <form> element. I only observed this in Firefox. There are no errors, but the new form tag is missing. It looks like Firefox spots a nested form situation and neutralizes the inner <form> tag. I am attaching the simple test I was running. Note that $('bar') returns null.

I was able to fix this by changing prototype.js:1182 (version 1.5.0) from:

range.selectNodeContents(element);

to:

range.selectNodeContents(element.parentNode);

My test page as well as my more complex application then both worked in both FF2 and IE6. Sorry I'm not set up for more comprehensive testing.

Attachments

form_replace_test.html (475 bytes) - added by cainlevy on 04/05/07 18:48:35.
test page
8010.diff (1.8 kB) - added by Tobie on 05/04/07 18:48:36.
Warning: this patch is against the DOM branch.

Change History

04/05/07 18:48:35 changed by cainlevy

  • attachment form_replace_test.html added.

test page

05/03/07 02:23:20 changed by Tobie

  • keywords changed from element.replace form to 1.5.2.
  • owner changed from sam to Tobie.
  • summary changed from Element.replace bug for <form> elements in Firefox to Element.replace does not properly replace a form in Firefox.

05/04/07 17:04:07 changed by therealadam

I've observed this bug as well, though I did not have nested forms. Making the noted change in prototype.js worked for me.

05/04/07 18:47:51 changed by Tobie

  • keywords changed from 1.5.2 to 1.5.2 ready.
  • summary changed from Element.replace does not properly replace a form in Firefox to [PATCH] Element.replace now properly replaces form elements in Firefox.

05/04/07 18:48:36 changed by Tobie

  • attachment 8010.diff added.

Warning: this patch is against the DOM branch.

05/12/07 05:02:00 changed by sam

  • status changed from new to closed.
  • resolution set to fixed.

(In [6725]) Merge -r6634:HEAD from ../branches/dom.

* Make Element#update and Element#insert work for SELECT tags in IE and Opera. [Tobie Langel]

* Make Element#insert and Element#update better handle TABLE related elements in IE and Opera. Closes #7776, #8040, #7550, #7776, #7938. [Tobie Langel]

* Make Element#readAttribute('title') work in Opera. [Tobie Langel]

* Make Element#replace work with form elements in Firefox and Safari. Closes #8010, #7989. [dsl239, Tobie Langel]

* Add Element#wrap which wraps the element inside a new one. Closes #5732. [P. Vande, Tobie Langel]

* Make Element into a constructor: new Element(tagName, attributes). Add Element#writeAttribute which accepts a hash of attributes or a name/value pair. Closes #7476. [Mislav Marohni?\196?\135, haraldmartin, Tobie Langel]

* Insertion overhaul: Add Element.insert(content[, position = 'Bottom']). Deprecate Insertion (kept for backwards compatibility). Make Ajax.Updater option.insertion accept both Insertion.Top or the now preferred 'Top'. Closes #7907. [Tobie Langel]