44var test = require ( 'tape' )
55var html = require ( 'hast-util-to-html' )
66var h = require ( 'hastscript' )
7+ var s = require ( 'hastscript/svg' )
78var u = require ( 'unist-builder' )
89var merge = require ( 'deepmerge' )
910var gh = require ( './lib/github' )
@@ -190,10 +191,7 @@ test('sanitize()', function(t) {
190191 )
191192
192193 st . deepEqual (
193- sanitize ( {
194- type : 'element' ,
195- tagName : 'div'
196- } ) ,
194+ sanitize ( { type : 'element' , tagName : 'div' } ) ,
197195 h ( ) ,
198196 'should support elements without children / properties'
199197 )
@@ -286,23 +284,13 @@ test('sanitize()', function(t) {
286284 )
287285
288286 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 } } ) ) ,
295288 h ( 'img' ) ,
296289 'should ignore `null`'
297290 )
298291
299292 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 } } ) ) ,
306294 h ( 'img' ) ,
307295 'should ignore `undefined`'
308296 )
@@ -316,15 +304,12 @@ test('sanitize()', function(t) {
316304 st . deepEqual (
317305 sanitize ( h ( 'div' , { name : 'getElementById' } ) ) ,
318306 h ( 'div' , { name : 'user-content-getElementById' } ) ,
319- 'should prevent clobbering (#1 )'
307+ 'should prevent clobbering (#2 )'
320308 )
321309
322310 st . deepEqual (
323311 sanitize (
324- u ( 'element' , {
325- tagName : 'img' ,
326- properties : { alt : { toString : toString } }
327- } )
312+ u ( 'element' , { tagName : 'img' , properties : { alt : { toString : toString } } } )
328313 ) ,
329314 h ( 'img' ) ,
330315 'should ignore objects'
@@ -334,15 +319,19 @@ test('sanitize()', function(t) {
334319 sanitize (
335320 u ( 'element' , {
336321 tagName : 'img' ,
337- properties : {
338- alt : [ 1 , true , 'three' , [ 4 ] , { toString : toString } ]
339- }
322+ properties : { alt : [ 1 , true , 'three' , [ 4 ] , { toString : toString } ] }
340323 } )
341324 ) ,
342325 h ( 'img' , { alt : [ 1 , true , 'three' ] } ) ,
343326 'should supports arrays'
344327 )
345328
329+ st . deepEqual (
330+ sanitize ( s ( 'svg' , { viewBox : '0 0 50 50' } , '!' ) ) ,
331+ u ( 'text' , '!' ) ,
332+ 'should ignore `svg` elements'
333+ )
334+
346335 st . test ( 'href`' , function ( sst ) {
347336 testAllURLs ( sst , 'a' , 'href' , {
348337 valid : {
0 commit comments