From: Elias Torres Date: Thu, 12 Nov 2009 22:27:11 +0000 (-0500) Subject: Fix for maintaining script inclusion order X-Git-Tag: v1.0.0~76^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8aae3263dd9ec9271d27a1b0aa4f04e8d6278d12;p=thirdparty%2Ftornado.git Fix for maintaining script inclusion order --- diff --git a/tornado/web.py b/tornado/web.py index 5d1ab2b64..bd8a6b690 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -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('' - for p in paths) + for p in resolved_paths) sloc = html.rindex('') html = html[:sloc] + js + '\n' + html[sloc:] if js_embed: