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) {