@@ -564,7 +564,7 @@ describe('html updaters', () => {
564564
565565 it ( 'unsafe html' , ( ) => {
566566 const getTemplate = ( { content } ) => {
567- return html `< div id ="target "> ${ unsafe ( content , 'html' ) } </ div > ` ;
567+ return html `< div id ="target "> ${ unsafe ( content ) } </ div > ` ;
568568 } ;
569569 const container = document . createElement ( 'div' ) ;
570570 document . body . append ( container ) ;
@@ -892,7 +892,7 @@ describe('html updaters', () => {
892892 const resolve = ( type , value ) => {
893893 switch ( type ) {
894894 case 'map' : return map ( value , item => item . id , item => html `< div id ="${ item . id } "> </ div > ` ) ;
895- case 'html' : return unsafe ( value , 'html' ) ;
895+ case 'html' : return unsafe ( value ) ;
896896 default : return value ; // E.g., an array, some text, null, undefined, etc.
897897 }
898898 } ;
@@ -1032,31 +1032,6 @@ describe('svg rendering', () => {
10321032} ) ;
10331033
10341034describe ( 'svg updaters' , ( ) => {
1035- it ( 'unsafe svg' , ( ) => {
1036- const getTemplate = ( { content } ) => {
1037- return html `
1038- < svg
1039- id ="target "
1040- xmlns ="http://www.w3.org/2000/svg "
1041- viewBox ="0 0 100 100 "
1042- style ="width: 100px; height: 100px; ">
1043- ${ unsafe ( content , 'svg' ) }
1044- </ svg >
1045- ` ;
1046- } ;
1047- const container = document . createElement ( 'div' ) ;
1048- document . body . append ( container ) ;
1049- render ( container , getTemplate ( { content : '<circle id="injected" r="10" cx="50" cy="50"></circle>' } ) ) ;
1050- assert ( ! ! container . querySelector ( '#injected' ) ) ;
1051- assert ( container . querySelector ( '#injected' ) . getBoundingClientRect ( ) . height = 20 ) ;
1052- assert ( container . querySelector ( '#injected' ) . getBoundingClientRect ( ) . width = 20 ) ;
1053- render ( container , getTemplate ( { content : '<circle id="injected" r="5" cx="50" cy="50"></circle>' } ) ) ;
1054- assert ( ! ! container . querySelector ( '#injected' ) ) ;
1055- assert ( container . querySelector ( '#injected' ) . getBoundingClientRect ( ) . height = 10 ) ;
1056- assert ( container . querySelector ( '#injected' ) . getBoundingClientRect ( ) . width = 10 ) ;
1057- container . remove ( ) ;
1058- } ) ;
1059-
10601035 it ( 'unsafeSVG' , ( ) => {
10611036 const getTemplate = ( { content } ) => {
10621037 return html `
@@ -1476,28 +1451,10 @@ describe('rendering errors', () => {
14761451
14771452
14781453 describe ( 'unsafe' , ( ) => {
1479- it ( 'throws if used on an unexpected language' , ( ) => {
1480- const expected = 'Unexpected unsafe language "css". Expected "html" or "svg".' ;
1481- const getTemplate = ( { maybe } ) => {
1482- return html `< div id ="target " maybe ="${ unsafe ( maybe , 'css' ) } "> </ div > ` ;
1483- } ;
1484- const container = document . createElement ( 'div' ) ;
1485- document . body . append ( container ) ;
1486- let actual ;
1487- try {
1488- render ( container , getTemplate ( { maybe : 'yes' } ) ) ;
1489- } catch ( error ) {
1490- actual = error . message ;
1491- }
1492- assert ( ! ! actual , 'No error was thrown.' ) ;
1493- assert ( actual === expected , actual ) ;
1494- container . remove ( ) ;
1495- } ) ;
1496-
14971454 it ( 'throws if used on an "attribute"' , ( ) => {
14981455 const expected = 'The unsafe update must be used on content, not on an attribute.' ;
14991456 const getTemplate = ( { maybe } ) => {
1500- return html `< div id ="target " maybe ="${ unsafe ( maybe , 'html' ) } "> </ div > ` ;
1457+ return html `< div id ="target " maybe ="${ unsafe ( maybe ) } "> </ div > ` ;
15011458 } ;
15021459 const container = document . createElement ( 'div' ) ;
15031460 document . body . append ( container ) ;
@@ -1515,7 +1472,7 @@ describe('rendering errors', () => {
15151472 it ( 'throws if used on a "boolean"' , ( ) => {
15161473 const expected = 'The unsafe update must be used on content, not on a boolean attribute.' ;
15171474 const getTemplate = ( { maybe } ) => {
1518- return html `< div id ="target " ?maybe ="${ unsafe ( maybe , 'html' ) } "> </ div > ` ;
1475+ return html `< div id ="target " ?maybe ="${ unsafe ( maybe ) } "> </ div > ` ;
15191476 } ;
15201477 const container = document . createElement ( 'div' ) ;
15211478 document . body . append ( container ) ;
@@ -1533,7 +1490,7 @@ describe('rendering errors', () => {
15331490 it ( 'throws if used on a "defined"' , ( ) => {
15341491 const expected = 'The unsafe update must be used on content, not on a defined attribute.' ;
15351492 const getTemplate = ( { maybe } ) => {
1536- return html `< div id ="target " ??maybe ="${ unsafe ( maybe , 'html' ) } "> </ div > ` ;
1493+ return html `< div id ="target " ??maybe ="${ unsafe ( maybe ) } "> </ div > ` ;
15371494 } ;
15381495 const container = document . createElement ( 'div' ) ;
15391496 document . body . append ( container ) ;
@@ -1551,7 +1508,7 @@ describe('rendering errors', () => {
15511508 it ( 'throws if used with a "property"' , ( ) => {
15521509 const expected = 'The unsafe update must be used on content, not on a property.' ;
15531510 const getTemplate = ( { maybe } ) => {
1554- return html `< div id ="target " .maybe ="${ unsafe ( maybe , 'html' ) } "> </ div > ` ;
1511+ return html `< div id ="target " .maybe ="${ unsafe ( maybe ) } "> </ div > ` ;
15551512 } ;
15561513 const container = document . createElement ( 'div' ) ;
15571514 document . body . append ( container ) ;
@@ -1569,7 +1526,7 @@ describe('rendering errors', () => {
15691526 it ( 'throws if used with "text"' , ( ) => {
15701527 const expected = 'The unsafe update must be used on content, not on text content.' ;
15711528 const getTemplate = ( { maybe } ) => {
1572- return html `< textarea id ="target "> ${ unsafe ( maybe , 'html' ) } </ textarea > ` ;
1529+ return html `< textarea id ="target "> ${ unsafe ( maybe ) } </ textarea > ` ;
15731530 } ;
15741531 const container = document . createElement ( 'div' ) ;
15751532 document . body . append ( container ) ;
@@ -1588,7 +1545,7 @@ describe('rendering errors', () => {
15881545 const getTemplate = ( { content } ) => {
15891546 return html `
15901547 < div id ="target ">
1591- ${ unsafe ( content , 'html' ) }
1548+ ${ unsafe ( content ) }
15921549 </ div >
15931550 ` ;
15941551 } ;
0 commit comments