github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

jquery / jquery-xpath

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 4
    • 1
  • Source
  • Commits
  • Network (1)
  • Graphs
  • Tree: 5f5b991
  • Branches (1)
    • master
  • Tags (0)
  • Comments
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Implement XPath functionality for those upgrading to jQuery 1.2 from jQuery 1.1. — Read more

or cancel

http://plugins.jquery.com/project/xpath

or cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Moving over from the jQuery SVN repository.
jeresig (author)
Sat Jul 25 07:16:48 -0700 2009
commit  5f5b9919ba26b70a1f9ce2a36c118fed4b2b55df
tree    ef2b6571216acdbedff20ec718fd5ce17d036a92
A jquery.xpath.js 49 •••••
0
jquery.xpath.js
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
0
@@ -0,0 +1,49 @@
0
+/*
0
+ * Simple XPath Compatibility Plugin for jQuery 1.1
0
+ * By John Resig
0
+ * Dual licensed under MIT and GPL.
0
+ */
0
+
0
+(function(jQuery){
0
+
0
+  var find = jQuery.find;
0
+
0
+  jQuery.find = function(selector, context){
0
+
0
+    // Remove the // at the start of the selector
0
+    selector = selector.replace(/^\/\//g, "");
0
+
0
+    // Convert the root / into a different context
0
+    if ( !selector.indexOf("/") ) {
0
+      context = context.documentElement;
0
+      selector = selector.replace(/^\/\w*/, "");
0
+      if ( !selector )
0
+        return [ context ];
0
+    }
0
+
0
+    // Convert // to " "
0
+    selector = selector.replace(/\/\//g, " ");
0
+
0
+    // Convert / to >
0
+    selector = selector.replace(/\//g, ">");
0
+
0
+    // Naively convert [elem] into :has(elem)
0
+    selector = selector.replace(/\[([^@].*?)\]/g, function(m, selector){
0
+      return ":has(" + selector + ")";
0
+    });
0
+
0
+    // Naively convert /.. into a new set of expressions
0
+    if ( selector.indexOf(">..") >= 0 ) {
0
+      var parts = selector.split(/>\.\.>?/g);
0
+      var cur = jQuery(parts[0], context);
0
+
0
+      for ( var i = 1; i < parts.length; i++ )
0
+        cur = cur.parent(parts[i]);
0
+
0
+      return cur.get();
0
+    }
0
+
0
+    return find(selector, context);
0
+  };
0
+
0
+})(jQuery);

Comments

Parsed with GitHub Flavored Markdown
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
GitHub™ is Logical Awesome ©2010 | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server
This feature is coming soon. Sit tight!