From 8e5eede8f82a5c472bd8caf029ea0c3d6ae4524a Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Thu, 27 Mar 2008 11:52:42 -0500 Subject: [PATCH 1/5] Adding empty .gitignore file so that 'dist' directory will be recognized by git. --- dist/.gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 dist/.gitignore diff --git a/dist/.gitignore b/dist/.gitignore new file mode 100644 index 0000000..e69de29 From d238a5558672b57545f18eb4fbff2207f0acb152 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Thu, 27 Mar 2008 15:00:35 -0500 Subject: [PATCH 2/5] Added 'prototype.js' to dist/.gitignore so it won't get added on checkins. --- dist/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/.gitignore b/dist/.gitignore index e69de29..ab1e075 100644 --- a/dist/.gitignore +++ b/dist/.gitignore @@ -0,0 +1 @@ +prototype.js \ No newline at end of file From 0c676269e9810495ab3c668c469e68a3d0bbb4be Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Fri, 28 Mar 2008 12:48:42 -0500 Subject: [PATCH 3/5] Fix issue where Safari 3 deletes custom properties from the document object when the page is returned to via the back button. --- src/event.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/event.js b/src/event.js index a271abe..5ccc055 100644 --- a/src/event.js +++ b/src/event.js @@ -188,10 +188,20 @@ Object.extend(Event, (function() { cache[id][eventName] = null; } + + // Internet Explorer needs to remove event handlers on page unload + // in order to avoid memory leaks. if (window.attachEvent) { window.attachEvent("onunload", destroyCache); } + // Safari has a dummy event handler on page unload so that it won't + // use its bfcache. Safari <= 3.1 has an issue with restoring the "document" + // object when page is returned to via the back button using its bfcache. + if (Prototype.Browser.WebKit) { + window.addEventListener('unload', Prototype.emptyFunction, false); + } + return { observe: function(element, eventName, handler) { element = $(element); From 55e5d645e14407d336293257d3a98eab0a06b7cd Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Fri, 28 Mar 2008 13:13:16 -0500 Subject: [PATCH 4/5] Fix issues where Firefox improperly returns the wrong node from a call to Event.element. Also fixes possible exception in Event.element in IE. --- CHANGELOG | 4 ++++ src/event.js | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ff224f0..8ab6ef8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +* Fix issues where Firefox improperly returns the wrong node from a call to Event.element. Also fixes possible exception in Event.element in IE. [jdalton, Andrew Dupont] + +* Fix issue where Safari 3 deletes custom properties from the document object when the page is returned to via the back button. [mzsanford, kangax, Andrew Dupont] + * Integrate support for the W3C Selectors API into the Selector class. Will now use the API when possible (browser supports the API *and* recognizes the given selector). Means minor changes to the semantics of :enabled, :disabled, and :empty in order to comply with CSS spec. * Avoid re-extending element in Element#getDimensions. [kangax] diff --git a/src/event.js b/src/event.js index 5ccc055..ee31b02 100644 --- a/src/event.js +++ b/src/event.js @@ -59,8 +59,23 @@ Event.Methods = (function() { isRightClick: function(event) { return isButton(event, 2) }, element: function(event) { - var node = Event.extend(event).target; - return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node); + event = Event.extend(event); + + var node = eventTarget, type = event.type; + + if (event.currentTarget) { + // Firefox screws up the "click" event when moving between radio buttons + // via arrow keys. It also screws up the "load" and "error" events on images, + // reporting the document as the target instead of the original image. + var currentTarget = event.currentTarget; + var tagName = currentTarget.tagName.toUpperCase(); + if (['load', 'error'].include(type) || + (tagName === 'INPUT' && currentTarget.type === 'radio' && type === 'click')) + node = currentTarget; + } + + return Element.extend(node && node.nodeType == Node.TEXT_NODE ? + node.parentNode : node); }, findElement: function(event, expression) { From 35a70710b0cec60598ff64715316032e16cd5c87 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Fri, 28 Mar 2008 13:31:36 -0500 Subject: [PATCH 5/5] Prevent exception when using Selector to search for an attribute that is not present. --- CHANGELOG | 2 ++ src/selector.js | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8ab6ef8..1db6079 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Prevent exception when using Selector to search for an attribute that is not present. [gryn, Andrew Dupont] + * Fix issues where Firefox improperly returns the wrong node from a call to Event.element. Also fixes possible exception in Event.element in IE. [jdalton, Andrew Dupont] * Fix issue where Safari 3 deletes custom properties from the document object when the page is returned to via the back button. [mzsanford, kangax, Andrew Dupont] diff --git a/src/selector.js b/src/selector.js index 424da5f..e03e0ab 100644 --- a/src/selector.js +++ b/src/selector.js @@ -644,13 +644,14 @@ Object.extend(Selector, { }, operators: { - '=': function(nv, v) { return nv == v; }, - '!=': function(nv, v) { return nv != v; }, - '^=': function(nv, v) { return nv.startsWith(v); }, + '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); }, + '$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); }, + '*=': function(nv, v) { return nv == v || nv && nv.include(v); }, '$=': function(nv, v) { return nv.endsWith(v); }, '*=': function(nv, v) { return nv.include(v); }, '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, - '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); } + '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() + + '-').include('-' + (v || "").toUpperCase() + '-'); } }, split: function(expression) {