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

Ticket #11434 (new defect)

Opened 2 years ago

Last modified 2 years ago

Several Bugs and Notes from Gaia Team

Reported by: kariem Assigned to: sam
Priority: normal Milestone: 2.x
Component: Prototype Version: edge
Severity: normal Keywords:
Cc:

Description

Hello,

I am one of the core developers behind Gaia Ajax Widgets http://ajaxwidgets.com/. We rely heavily on the awesome prototype JS library. We have several simple patches and fixes that we add to prototype.js, every time we upgrade our product to use a newer version of prototype. We thought you would be interested if we share those with you. I will be talking about the latest release of prototype.js (1.6.0.2)
Here it goes:

Patch to support broken connections in Firefox


- Function that has the problem (line number: 1188):

request: function(url)

- Fix: Before this line of code (line number: 1214):

this.transport.open(this.method.toUpperCase(), this.url, this.options.asynchronous);

we add the following line of code:

if (Prototype.Browser.Gecko)
  this.transport.onerror = function(e){this.dispatchException(e);}.bind(this);


Problem causes element.style to be undefined in IE6


- Line numbers: 2238, 2239 and 2240

var offsetParent = element.getOffsetParent();
if (offsetParent && offsetParent.getStyle('position') === 'fixed')
  offsetParent.setStyle({ zoom: 1 });

- Fix: We commented those lines out

Problem that causes JS error when Event.stop is called


- Symptom: When Event.stop(event) is called sometimes it gives an error, undefined function event.preventDefault in the browsers that only support event.stopPropagation and vice versa

- Function that has the problem: Event.Methods, specifically the stop function (line number: 3799)

stop: function(event)

- Fix: We added if checks before the calls:

if( event.preventDefault )
  event.preventDefault();
if( event.stopPropagation )
  event.stopPropagation();


Accurate Value for cumulativeOffset


This fix was introduced to us by one of our customers http://www.multicase.no/
- Function that has the problem (line number: 2004):

cumulativeOffset: function(element)

- Fix provided by Odd Henrik from Multicase:

cumulativeOffset: function(element) {
    var valueT = 0, valueL = 0;
    var lastElement = element;

    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      
      // Odd-Henrik - MultiCase patch...
      valueT += parseInt(element.style.borderTopWidth) || 0;
      valueL += parseInt(element.style.borderLeftWidth) || 0;
      
      element = element.offsetParent;
    } while (element);
    return Element._returnOffset(valueL - (parseInt(lastElement.style.borderLeftWidth) || 0), 
      valueT - (parseInt(lastElement.style.borderTopWidth) || 0));
  },



I included the patched version of 1.6.0.2 that we are using in our product, you can search for "gaia" to find our fixes and search for "Odd-Henrik" to find his fix.

Thank you for this awesome library,
Kariem Ali

Attachments

prototype.js (124.1 kB) - added by kariem on 03/26/08 23:27:27.
Gaia Patched Version of Prototype 1.6.0.2

Change History

03/26/08 23:27:27 changed by kariem

  • attachment prototype.js added.

Gaia Patched Version of Prototype 1.6.0.2

04/01/08 20:55:23 changed by jdalton

the CumulativeOffset fix would address this ticket:
http://dev.rubyonrails.org/ticket/10149

04/02/08 21:43:08 changed by jdalton

  • priority changed from high to normal.
  • type changed from enhancement to defect.

(follow-up: ↓ 4 ) 04/03/08 03:54:16 changed by kangax

Just a few notes/questions:

1) If we support error/timeout, it would need to be cross-browser. I think we have it planned for the near future releases. 2), 4) are known issues, we just need proper tests. 3) Which browsers do not support preventDefault and/or stopPropagation?

Thanks.

(in reply to: ↑ 3 ) 04/03/08 13:46:54 changed by kariem

Hello,

Great news about the other issues but regarding number three, preventDefault and stopPropagation cause a JS error in IE if they do not have the above if checks around them.

Thank you,
Kariem

Replying to kangax:

Just a few notes/questions: 1) If we support error/timeout, it would need to be cross-browser. I think we have it planned for the near future releases. 2), 4) are known issues, we just need proper tests. 3) Which browsers do not support preventDefault and/or stopPropagation? Thanks.

(follow-up: ↓ 7 ) 04/03/08 13:54:58 changed by jdalton

2) has a patch and test here:

http://dev.rubyonrails.org/ticket/11473

3) should be fixed already in 1.6.0.2

  if (Prototype.Browser.IE) {
    Object.extend(methods, {
      stopPropagation: function() { this.cancelBubble = true },
      preventDefault:  function() { this.returnValue = false },
      inspect: function() { return "[object Event]" }
    });
    ...

Awesome finds Kariem Ali :)

04/03/08 13:58:42 changed by jdalton

Ajax timeout/ connection error discussed here:
http://dev.rubyonrails.org/ticket/10191

(in reply to: ↑ 5 ; follow-up: ↓ 8 ) 04/03/08 14:05:57 changed by kariem

Thanks a lot :)
regarding issue 3, we still had that problem after upgrading to 1.6.0.2 and testing on IE6, I don't remember if it happened in IE7 as well.

Kariem

Replying to jdalton:

2) has a patch and test here:
http://dev.rubyonrails.org/ticket/11473 3) should be fixed already in 1.6.0.2 {{{ if (Prototype.Browser.IE) { Object.extend(methods, { stopPropagation: function() { this.cancelBubble = true }, preventDefault: function() { this.returnValue = false }, inspect: function() { return "[object Event]" } }); ... }}} Awesome finds Kariem Ali :)

(in reply to: ↑ 7 ; follow-up: ↓ 9 ) 04/05/08 12:52:04 changed by Tobie

Replying to kariem:

regarding issue 3, we still had that problem after upgrading to 1.6.0.2 and testing on IE6, I don't remember if it happened in IE7 as well.

Are you using Event.stop(event) or event.stop()?

(in reply to: ↑ 8 ; follow-up: ↓ 10 ) 04/06/08 17:05:43 changed by kariem

We use Event.stop(event)

Replying to Tobie:

Replying to kariem:

regarding issue 3, we still had that problem after upgrading to 1.6.0.2 and testing on IE6, I don't remember if it happened in IE7 as well.

Are you using Event.stop(event) or event.stop()?

(in reply to: ↑ 9 ) 04/14/08 12:11:44 changed by kangax

Replying to kariem:

We use Event.stop(event) Replying to Tobie:

Replying to kariem:

regarding issue 3, we still had that problem after upgrading to 1.6.0.2 and testing on IE6, I don't remember if it happened in IE7 as well.

Are you using Event.stop(event) or event.stop()?

Would you be able to provide a simple test case when this happens? Thanks.