Author: ubernostrum
Date: 2010-03-03 02:01:48 -0600 (Wed, 03 Mar 2010)
New Revision: 12663
Modified:
django/trunk/django/forms/widgets.py
django/trunk/tests/regressiontests/forms/media.py
Log:
Fixed #12879: Declaring the same JS file multiple times in a single Media
instance now only includes that file once.
Modified: django/trunk/django/forms/widgets.py
===================================================================
--- django/trunk/django/forms/widgets.py 2010-03-02 22:02:02 UTC (rev
12662)
+++ django/trunk/django/forms/widgets.py 2010-03-03 08:01:48 UTC (rev
12663)
@@ -75,7 +75,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/trunk/tests/regressiontests/forms/media.py
===================================================================
--- django/trunk/tests/regressiontests/forms/media.py 2010-03-02 22:02:02 UTC
(rev 12662)
+++ django/trunk/tests/regressiontests/forms/media.py 2010-03-03 08:01:48 UTC
(rev 12663)
@@ -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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.