4
4
var test = require ( 'tape' )
5
5
var html = require ( 'hast-util-to-html' )
6
6
var h = require ( 'hastscript' )
7
+ var s = require ( 'hastscript/svg' )
7
8
var u = require ( 'unist-builder' )
8
9
var merge = require ( 'deepmerge' )
9
10
var gh = require ( './lib/github' )
@@ -190,10 +191,7 @@ test('sanitize()', function(t) {
190
191
)
191
192
192
193
st . deepEqual (
193
- sanitize ( {
194
- type : 'element' ,
195
- tagName : 'div'
196
- } ) ,
194
+ sanitize ( { type : 'element' , tagName : 'div' } ) ,
197
195
h ( ) ,
198
196
'should support elements without children / properties'
199
197
)
@@ -286,23 +284,13 @@ test('sanitize()', function(t) {
286
284
)
287
285
288
286
st . deepEqual (
289
- sanitize (
290
- u ( 'element' , {
291
- tagName : 'img' ,
292
- properties : { alt : null }
293
- } )
294
- ) ,
287
+ sanitize ( u ( 'element' , { tagName : 'img' , properties : { alt : null } } ) ) ,
295
288
h ( 'img' ) ,
296
289
'should ignore `null`'
297
290
)
298
291
299
292
st . deepEqual (
300
- sanitize (
301
- u ( 'element' , {
302
- tagName : 'img' ,
303
- properties : { alt : undefined }
304
- } )
305
- ) ,
293
+ sanitize ( u ( 'element' , { tagName : 'img' , properties : { alt : undefined } } ) ) ,
306
294
h ( 'img' ) ,
307
295
'should ignore `undefined`'
308
296
)
@@ -316,15 +304,12 @@ test('sanitize()', function(t) {
316
304
st . deepEqual (
317
305
sanitize ( h ( 'div' , { name : 'getElementById' } ) ) ,
318
306
h ( 'div' , { name : 'user-content-getElementById' } ) ,
319
- 'should prevent clobbering (#1 )'
307
+ 'should prevent clobbering (#2 )'
320
308
)
321
309
322
310
st . deepEqual (
323
311
sanitize (
324
- u ( 'element' , {
325
- tagName : 'img' ,
326
- properties : { alt : { toString : toString } }
327
- } )
312
+ u ( 'element' , { tagName : 'img' , properties : { alt : { toString : toString } } } )
328
313
) ,
329
314
h ( 'img' ) ,
330
315
'should ignore objects'
@@ -334,15 +319,19 @@ test('sanitize()', function(t) {
334
319
sanitize (
335
320
u ( 'element' , {
336
321
tagName : 'img' ,
337
- properties : {
338
- alt : [ 1 , true , 'three' , [ 4 ] , { toString : toString } ]
339
- }
322
+ properties : { alt : [ 1 , true , 'three' , [ 4 ] , { toString : toString } ] }
340
323
} )
341
324
) ,
342
325
h ( 'img' , { alt : [ 1 , true , 'three' ] } ) ,
343
326
'should supports arrays'
344
327
)
345
328
329
+ st . deepEqual (
330
+ sanitize ( s ( 'svg' , { viewBox : '0 0 50 50' } , '!' ) ) ,
331
+ u ( 'text' , '!' ) ,
332
+ 'should ignore `svg` elements'
333
+ )
334
+
346
335
st . test ( 'href`' , function ( sst ) {
347
336
testAllURLs ( sst , 'a' , 'href' , {
348
337
valid : {
0 commit comments