@@ -25,6 +25,11 @@ describe('svg+text utils', function() {
25
25
expect ( a . attr ( 'xlink:show' ) ) . toBe ( href === null ? null : 'new' ) ;
26
26
}
27
27
28
+ function assertTspanStyle ( node , style ) {
29
+ var tspan = node . select ( 'tspan' ) ;
30
+ expect ( tspan . attr ( 'style' ) ) . toBe ( style ) ;
31
+ }
32
+
28
33
function assertAnchorAttrs ( node ) {
29
34
var a = node . select ( 'a' ) ;
30
35
@@ -134,5 +139,50 @@ describe('svg+text utils', function() {
134
139
assertAnchorLink ( node , 'https://abc.com/myFeature.jsp?name=abc&pwd=def' ) ;
135
140
} ) ;
136
141
} ) ;
142
+
143
+ it ( 'allow basic spans' , function ( ) {
144
+ var node = mockTextSVGElement (
145
+ '<span>text</span>'
146
+ ) ;
147
+
148
+ expect ( node . text ( ) ) . toEqual ( 'text' ) ;
149
+ assertTspanStyle ( node , null ) ;
150
+ } ) ;
151
+
152
+ it ( 'ignore unquoted styles in spans' , function ( ) {
153
+ var node = mockTextSVGElement (
154
+ '<span style=unquoted>text</span>'
155
+ ) ;
156
+
157
+ expect ( node . text ( ) ) . toEqual ( 'text' ) ;
158
+ assertTspanStyle ( node , null ) ;
159
+ } ) ;
160
+
161
+ it ( 'allow quoted styles in spans' , function ( ) {
162
+ var node = mockTextSVGElement (
163
+ '<span style="quoted: yeah;">text</span>'
164
+ ) ;
165
+
166
+ expect ( node . text ( ) ) . toEqual ( 'text' ) ;
167
+ assertTspanStyle ( node , 'quoted: yeah;' ) ;
168
+ } ) ;
169
+
170
+ it ( 'ignore extra stuff after span styles' , function ( ) {
171
+ var node = mockTextSVGElement (
172
+ '<span style="quoted: yeah;"disallowed: indeed;">text</span>'
173
+ ) ;
174
+
175
+ expect ( node . text ( ) ) . toEqual ( 'text' ) ;
176
+ assertTspanStyle ( node , 'quoted: yeah;' ) ;
177
+ } ) ;
178
+
179
+ it ( 'escapes HTML entities in span styles' , function ( ) {
180
+ var node = mockTextSVGElement (
181
+ '<span style="quoted: yeah&\';;">text</span>'
182
+ ) ;
183
+
184
+ expect ( node . text ( ) ) . toEqual ( 'text' ) ;
185
+ assertTspanStyle ( node , 'quoted: yeah&\';;' ) ;
186
+ } ) ;
137
187
} ) ;
138
188
} ) ;
0 commit comments