]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fix for maintaining script inclusion order
authorElias Torres <elias@torrez.us>
Thu, 12 Nov 2009 22:27:11 +0000 (17:27 -0500)
committerBen Darnell <bdarnell@beaker.local>
Wed, 3 Feb 2010 20:11:09 +0000 (12:11 -0800)
tornado/web.py

index 5d1ab2b6476c680aac3b0017790768cda617cefe..bd8a6b690e9a0bdad063ebd31ce6206411369a12 100644 (file)
@@ -347,15 +347,25 @@ class RequestHandler(object):
             head_part = module.html_head()
             if head_part: html_heads.append(_utf8(head_part))
         if js_files:
-            paths = set()
+            paths = {}
             for path in js_files:
                 if not path.startswith("/") and not path.startswith("http:"):
-                    paths.add(self.static_url(path))
+                    paths[path] = self.static_url(path)
                 else:
-                    paths.add(path)
+                    paths[path] = path
+
+            used_paths = set()
+            resolved_paths = []
+            for path in js_files:
+              resolved = paths[path]
+              if resolved in used_paths:
+                continue
+              used_paths.add(resolved)
+              resolved_paths.append(resolved)
+
             js = ''.join('<script src="' + escape.xhtml_escape(p) +
                          '" type="text/javascript"></script>'
-                         for p in paths)
+                         for p in resolved_paths)
             sloc = html.rindex('</body>')
             html = html[:sloc] + js + '\n' + html[sloc:]
         if js_embed: