File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
tests/regressiontests/forms Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,9 @@ def add_js(self, data):
82
82
def add_css (self , data ):
83
83
if data :
84
84
for medium , paths in data .items ():
85
- self ._css .setdefault (medium , []).extend ([path for path in paths if path not in self ._css [medium ]])
85
+ for path in paths :
86
+ if not self ._css .get (medium ) or path not in self ._css [medium ]:
87
+ self ._css .setdefault (medium , []).append (path )
86
88
87
89
def __add__ (self , other ):
88
90
combined = Media ()
Original file line number Diff line number Diff line change 112
112
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
113
113
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
114
114
115
- # Regression check for #12879: specifying the same JS file multiple
116
- # times in a single Media instance should result in that file only
117
- # being included once.
115
+ # Regression check for #12879: specifying the same CSS or JS file
116
+ # multiple times in a single Media instance should result in that file
117
+ # only being included once.
118
118
>>> class MyWidget4(TextInput):
119
119
... class Media:
120
+ ... css = {'all': ('/path/to/css1', '/path/to/css1')}
120
121
... js = ('/path/to/js1', '/path/to/js1')
121
122
122
123
>>> w4 = MyWidget4()
123
124
>>> print w4.media
125
+ <link href="/path/to/css1" type="text/css" media="all" rel="stylesheet" />
124
126
<script type="text/javascript" src="/path/to/js1"></script>
125
127
126
128
You can’t perform that action at this time.
0 commit comments