Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update Railties to Prototype 1.3.1

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1807 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 1911f8eee928915f1020753a4a3ba34c81131a66 1 parent 325c5ef
Sam Stephenson sstephenson authored
Showing with 50 additions and 39 deletions.
  1. +50 −39 railties/html/javascripts/prototype.js
89 railties/html/javascripts/prototype.js
View
@@ -1,4 +1,4 @@
-/* Prototype JavaScript framework, version 1.3.0
+/* Prototype JavaScript framework, version 1.3.1
* (c) 2005 Sam Stephenson <sam@conio.net>
*
* THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
@@ -11,7 +11,7 @@
/*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.3.0',
+ Version: '1.3.1',
emptyFunction: function() {}
}
@@ -266,12 +266,16 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({
respondToReadyState: function(readyState) {
var event = Ajax.Request.Events[readyState];
- if (event == 'Complete' && this.responseIsFailure())
+ if (event == 'Complete')
(this.options['on' + this.transport.status]
- || this.options.onFailure
+ || this.options['on' + this.responseIsSuccess() ? 'Success' : 'Failure']
|| Prototype.emptyFunction)(this.transport);
- (this.options['on' + event] || Prototype.emptyFunction)(this.transport);
+ (this.options['on' + event] || Prototype.emptyFunction)(this.transport);
+
+ /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
+ if (event == 'Complete')
+ this.transport.onreadystatechange = Prototype.emptyFunction;
}
});
@@ -292,7 +296,7 @@ Ajax.Updater.prototype.extend(Ajax.Request.prototype).extend({
var onComplete = this.options.onComplete || Prototype.emptyFunction;
this.options.onComplete = (function() {
this.updateContent();
- onComplete(this.transport);
+ onComplete(this.transport);
}).bind(this);
this.request(url);
@@ -889,53 +893,60 @@ Object.extend(Event, {
return element;
},
+ observers: false,
+
+ _observeAndCache: function(element, name, observer, useCapture) {
+ if (!this.observers) this.observers = [];
+ if (element.addEventListener) {
+ this.observers.push([element, name, observer, useCapture]);
+ element.addEventListener(name, observer, useCapture);
+ } else if (element.attachEvent) {
+ this.observers.push([element, name, observer, useCapture]);
+ element.attachEvent('on' + name, observer);
+ }
+ },
+
+ unloadCache: function() {
+ if (!Event.observers) return;
+ for (var i = 0; i < Event.observers.length; i++) {
+ Event.stopObserving.apply(this, Event.observers[i]);
+ Event.observers[i][0] = null;
+ }
+ Event.observers = false;
+ },
+
observe: function(element, name, observer, useCapture) {
var element = $(element);
useCapture = useCapture || false;
- if (name == 'keypress') {
- if (navigator.appVersion.indexOf('AppleWebKit') > 0) {
- element.addEventListener('keydown', observer, useCapture);
- return;
- }
- if (element.addEventListener) {
- element.addEventListener('keypress', observer, useCapture);
- } else if (element.attachEvent) {
- element.attachEvent('onkeydown', observer);
- }
- } else {
- if (element.addEventListener) {
- element.addEventListener(name, observer, useCapture);
- } else if (element.attachEvent) {
- element.attachEvent('on' + name, observer);
- }
- }
+ if (name == 'keypress' &&
+ ((navigator.appVersion.indexOf('AppleWebKit') > 0)
+ || element.attachEvent))
+ name = 'keydown';
+
+ this._observeAndCache(element, name, observer, useCapture);
},
stopObserving: function(element, name, observer, useCapture) {
var element = $(element);
useCapture = useCapture || false;
- if (name == 'keypress') {
- if (navigator.appVersion.indexOf('AppleWebKit') > 0) {
- element.removeEventListener('keydown', observer, useCapture);
- return;
- }
- if (element.removeEventListener) {
- element.removeEventListener('keypress', observer, useCapture);
- } else if (element.detachEvent) {
- element.detachEvent('onkeydown', observer);
- }
- } else {
- if (element.removeEventListener) {
- element.removeEventListener(name, observer, useCapture);
- } else if (element.detachEvent) {
- element.detachEvent('on' + name, observer);
- }
+ if (name == 'keypress' &&
+ ((navigator.appVersion.indexOf('AppleWebKit') > 0)
+ || element.detachEvent))
+ name = 'keydown';
+
+ if (element.removeEventListener) {
+ element.removeEventListener(name, observer, useCapture);
+ } else if (element.detachEvent) {
+ element.detachEvent('on' + name, observer);
}
}
});
+/* prevent memory leaks in IE */
+Event.observe(window, 'unload', Event.unloadCache, false);
+
var Position = {
// set to true if needed, warning: firefox performance problems
Please sign in to comment.
Something went wrong with that request. Please try again.