Author: ubernostrum Date: 2010-03-03 02:03:47 -0600 (Wed, 03 Mar 2010) New Revision: 12664
Modified: django/branches/releases/1.1.X/django/forms/widgets.py django/branches/releases/1.1.X/tests/regressiontests/forms/media.py Log: [1.1.X] Fixed #12879: Declaring the same JS file multiple times in a single Media instance now only includes that file once. Backport of [12663] from trunk. Modified: django/branches/releases/1.1.X/django/forms/widgets.py =================================================================== --- django/branches/releases/1.1.X/django/forms/widgets.py 2010-03-03 08:01:48 UTC (rev 12663) +++ django/branches/releases/1.1.X/django/forms/widgets.py 2010-03-03 08:03:47 UTC (rev 12664) @@ -80,7 +80,9 @@ def add_js(self, data): if data: - self._js.extend([path for path in data if path not in self._js]) + for path in data: + if path not in self._js: + self._js.append(path) def add_css(self, data): if data: Modified: django/branches/releases/1.1.X/tests/regressiontests/forms/media.py =================================================================== --- django/branches/releases/1.1.X/tests/regressiontests/forms/media.py 2010-03-03 08:01:48 UTC (rev 12663) +++ django/branches/releases/1.1.X/tests/regressiontests/forms/media.py 2010-03-03 08:03:47 UTC (rev 12664) @@ -112,6 +112,18 @@ <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> +# Regression check for #12879: specifying the same JS file multiple +# times in a single Media instance should result in that file only +# being included once. +>>> class MyWidget4(TextInput): +... class Media: +... js = ('/path/to/js1', '/path/to/js1') + +>>> w4 = MyWidget4() +>>> print w4.media +<script type="text/javascript" src="/path/to/js1"></script> + + ############################################################### # Property-based media definitions ############################################################### -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.