Changeset 8222
- Timestamp:
- 11/27/07 18:21:50 (1 year ago)
- Files:
-
- spinoffs/prototype/trunk/CHANGELOG (modified) (1 diff)
- spinoffs/prototype/trunk/src/prototype.js (modified) (1 diff)
- spinoffs/prototype/trunk/src/selector.js (modified) (2 diffs)
- spinoffs/prototype/trunk/test/unit/selector.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinoffs/prototype/trunk/CHANGELOG
r8221 r8222 1 * Re-enable the XPath approach in Selector for Safari 3. Falls back to the non-XPath version when it sees a problematic token. [Andrew Dupont] 2 1 3 * Fix a bug in the IE-specific Element#descendantOf logic. [Nicholas, Andrew Dupont] 2 4 spinoffs/prototype/trunk/src/prototype.js
r7962 r8222 31 31 Prototype.BrowserFeatures.SpecificElementExtensions = false; 32 32 33 if (Prototype.Browser.WebKit)34 Prototype.BrowserFeatures.XPath = false;35 33 36 34 <%= include 'base.js', 'string.js' %> spinoffs/prototype/trunk/src/selector.js
r8151 r8222 9 9 }, 10 10 11 shouldUseXPath: function() { 12 if (!Prototype.BrowserFeatures.XPath) return false; 13 14 var e = this.expression; 15 16 // Safari 3 chokes on :*-of-type and :empty 17 if (Prototype.Browser.WebKit && 18 (e.include("-of-type") || e.include(":empty"))) 19 return false; 20 21 // XPath can't do namespaced attributes, nor can it read 22 // the "checked" property from DOM nodes 23 if ((/(\[[\w-]*?:|:checked)/).test(this.expression)) 24 return false; 25 26 return true; 27 }, 28 11 29 compileMatcher: function() { 12 // Selectors with namespaced attributes can't use the XPath version 13 if (Prototype.BrowserFeatures.XPath && !(/(\[[\w-]*?:|:checked)/).test(this.expression)) 30 if (this.shouldUseXPath()) 14 31 return this.compileXPathMatcher(); 15 32 … … 134 151 className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", 135 152 id: "[@id='#{1}']", 136 attrPresence: "[@#{1}]", 153 attrPresence: function(m) { 154 m[1] = m[1].toLowerCase(); 155 return new Template("[@#{1}]").evaluate(m); 156 }, 137 157 attr: function(m) { 158 m[1] = m[1].toLowerCase(); 138 159 m[3] = m[5] || m[6]; 139 160 return new Template(Selector.xpath.operators[m[2]]).evaluate(m); spinoffs/prototype/trunk/test/unit/selector.html
r8071 r8222 159 159 160 160 testSelectorWithTagNameAndAttributeExistence: function() {with(this) { 161 assertEnumEqual($$('#fixtures h1'), $$('h1[class]') );162 assertEnumEqual($$('#fixtures h1'), $$('h1[CLASS]') );163 assertEnumEqual([$('item_3')], $$('li#item_3[class]') );161 assertEnumEqual($$('#fixtures h1'), $$('h1[class]'), 'h1[class]'); 162 assertEnumEqual($$('#fixtures h1'), $$('h1[CLASS]'), 'h1[CLASS]'); 163 assertEnumEqual([$('item_3')], $$('li#item_3[class]'), 'li#item_3[class]'); 164 164 }}, 165 165