[bugzilla-gnome-org-extensions] flattener.py: Handle jQuery extensions



commit 03f63cc2eb8212bb8d9e15e42529f0fd79f5888f
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Oct 10 17:28:09 2009 -0400

    flattener.py: Handle jQuery extensions
    
    Fix 'jQuery.fn.foo = function() { ...};':
    
    - Handle assignment to elements with more than
      two components.
    - Recognize jQuery as a toplevel namespace of its own.

 flattener.py |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/flattener.py b/flattener.py
index bbeaf85..fd528d6 100755
--- a/flattener.py
+++ b/flattener.py
@@ -11,9 +11,9 @@ r"""
 \s*
 (?:^
 include\s*\(\s*\'([^\']+)\'\s*\)\s*; |
-(?:function\s+(\w+)\s*     (\(.*;|%(c)s^\})) |
-(?:(\w+)\.(\w+)\s*=\s*       (.*;|%(c)s^[\]\}];)) |
-(?:(?:const|let|var)\s+(\w+) (.*;|%(c)s^[\]\}];)) |
+(?:function\s+(\w+)\s*           (\(.*;|%(c)s^\})) |
+(?:(\w+)\.(\w+(?:\.\w+)*)\s*=\s* (.*;|%(c)s^[\]\}];)) |
+(?:(?:const|let|var)\s+(\w+)     (.*;|%(c)s^[\]\}];)) |
 /\*(?:[^*]+|\*[^/])*\*/ |
 //.*
 [ \t]*\n)
@@ -90,7 +90,7 @@ if (!console) {
                     add_local(m.group(2))
                     print >>self.outf, "%s.%s = function%s;" % (namespace, m.group(2), 
substitute_locals(m.group(3)))
             elif m.group(4) is not None:
-                if namespace is None:
+                if m.group(4) == "jQuery" or namespace is None:
                     print >>self.outf, "%s.%s = %s" % (m.group(4), m.group(5), m.group(6))
                 else:
                     print >>self.outf, "%s.%s.%s = %s" % (namespace, m.group(4), m.group(5), 
substitute_locals(m.group(6)))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]