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

Ticket #11412 (closed defect: untested)

Opened 8 months ago

Last modified 8 months ago

Element.update call does not embed script tags in Firefox with Firebug enabled

Reported by: jamesho Assigned to: sam
Priority: low Milestone: 2.x
Component: Prototype Version: edge
Severity: minor Keywords: page.replace replace firefox ext 2.0
Cc: jamesh@nulogy.com

Description

Problem:

  • Using page.replace with a partial that contains javascript does not work properly in Firefox with Firebug enabled
  • The html will be replaced but the javascript tags are ignored

Analysis:

  • In dom.js, the replace method calls the defer method which has a default wait time of 10 ms
    content.evalScripts.bind(content).defer();
    
  • It seems that the time it takes to render the html is greater than 10 ms when Firebug is enabled

Solution:

  • Moved the defer method to the last line
  • Required the use of more local variables, and can't re-use the following line anymore:
    element.parentNode.replaceChild(content, element);
    

Attachments

changed-dom-replace-patch.diff (1.0 kB) - added by jamesho on 03/24/08 17:15:30.
Patch that fixes the dom.js replace method to work in FireFox / Firebug

Change History

03/24/08 17:15:30 changed by jamesho

  • attachment changed-dom-replace-patch.diff added.

Patch that fixes the dom.js replace method to work in FireFox / Firebug

03/24/08 17:16:47 changed by jamesho

We could have also changed the defer method to wait a bit longer - but that seemed like more guess-work than necessary.

03/24/08 17:17:50 changed by jamesho

  • keywords set to page.replace replace firefox firebug.

03/24/08 17:20:36 changed by jamesho

  • cc set to jamesh@nulogy.com.

(follow-up: ↓ 5 ) 03/24/08 17:38:52 changed by Tobie

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

Can you please provide a failing test case against trunk ?

Closing as untested in the meantime. Feel free to reopen.

Thanks.

(in reply to: ↑ 4 ) 03/24/08 18:14:23 changed by jamesho

I'm not sure how to create an automated test case for this.

The problem being: how do I simulate the "slowness" or "delay" caused by Firebug in an ajax call to the following line?

content = range.createContextualFragment(content.stripScripts());

If you have any ideas as to how to achieve this, then please let me know. Otherwise, I'm not sure if this is even test-able, since it is fairly browser + plug-in specific.

Perhaps one way is to pass in content that is composed of many nodes.

03/24/08 19:41:59 changed by jamesho

  • keywords changed from page.replace replace firefox firebug to page.replace replace firefox ext 2.0.

Upon closer examination, the ticket is invalid. The issue has to do with EXT2.0 overriding the defer method and thereby causing the replace method to evaluate the scripts immediately instead of waiting for the 10ms duration as specified by the prototype's defer method.

This problem exists in FireFox and with EXT 2.0. This problem does not seem to exist in IE 6.0.

There is an open ticket for this defect: #11227