@@ -1600,45 +1600,44 @@ describe('render', () => {
1600
1600
} ) ;
1601
1601
1602
1602
describe ( 'Render Options' , ( ) => {
1603
- describe ( 'Attribute Hook' , ( ) => {
1604
- it ( 'Transforms attributes with custom attrHook option' , ( ) => {
1605
- function attrHook ( name ) {
1606
- const DASHED_ATTRS = / ^ ( a c c e p t C | h t t p E | ( c l i p | c o l o r | f i l l | f o n t | g l y p h | m a r k e r | s t o p | s t r o k e | t e x t | v e r t ) [ A - Z ] ) / ;
1607
- const CAMEL_ATTRS = / ^ ( i s P | v i e w B ) / ;
1608
- const COLON_ATTRS = / ^ ( x l i n k | x m l | x m l n s ) ( [ A - Z ] ) / ;
1609
- const CAPITAL_REGEXP = / ( [ A - Z ] ) / g;
1610
- if ( CAMEL_ATTRS . test ( name ) ) return name ;
1611
- if ( DASHED_ATTRS . test ( name ) )
1612
- return name . replace ( CAPITAL_REGEXP , '-$1' ) . toLowerCase ( ) ;
1613
- if ( COLON_ATTRS . test ( name ) )
1614
- return name . replace ( CAPITAL_REGEXP , ':$1' ) . toLowerCase ( ) ;
1615
- return name . toLowerCase ( ) ;
1616
- }
1603
+ it ( 'transforms attributes with custom attributeHook option' , ( ) => {
1604
+ function attributeHook ( name ) {
1605
+ const DASHED_ATTRS = / ^ ( a c c e p t C | h t t p E | ( c l i p | c o l o r | f i l l | f o n t | g l y p h | m a r k e r | s t o p | s t r o k e | t e x t | v e r t ) [ A - Z ] ) / ;
1606
+ const CAMEL_ATTRS = / ^ ( i s P | v i e w B ) / ;
1607
+ const COLON_ATTRS = / ^ ( x l i n k | x m l | x m l n s ) ( [ A - Z ] ) / ;
1608
+ const CAPITAL_REGEXP = / ( [ A - Z ] ) / g;
1609
+ if ( CAMEL_ATTRS . test ( name ) ) return name ;
1610
+ if ( DASHED_ATTRS . test ( name ) )
1611
+ return name . replace ( CAPITAL_REGEXP , '-$1' ) . toLowerCase ( ) ;
1612
+ if ( COLON_ATTRS . test ( name ) )
1613
+ return name . replace ( CAPITAL_REGEXP , ':$1' ) . toLowerCase ( ) ;
1614
+ return name . toLowerCase ( ) ;
1615
+ }
1617
1616
1618
- const content = (
1619
- < html >
1620
- < head >
1621
- < meta charSet = "utf=8" />
1622
- < meta httpEquiv = "refresh" />
1623
- < link rel = "preconnect" href = "https://foo.com" crossOrigin />
1624
- </ head >
1625
- < body >
1626
- < img srcSet = "foo.png, foo2.png 2x" />
1627
- < svg xmlSpace = "preserve" viewBox = "0 0 10 10" fillRule = "nonzero" >
1628
- < foreignObject >
1629
- < div xlinkHref = "#" />
1630
- </ foreignObject >
1631
- </ svg >
1632
- </ body >
1633
- </ html >
1634
- ) ;
1617
+ const content = (
1618
+ < html >
1619
+ < head >
1620
+ < meta charSet = "utf=8" />
1621
+ < meta httpEquiv = "refresh" />
1622
+ < link rel = "preconnect" href = "https://foo.com" crossOrigin />
1623
+ < link rel = "preconnect" href = "https://bar.com" crossOrigin = { false } />
1624
+ </ head >
1625
+ < body >
1626
+ < img srcSet = "foo.png, foo2.png 2x" />
1627
+ < svg xmlSpace = "preserve" viewBox = "0 0 10 10" fillRule = "nonzero" >
1628
+ < foreignObject >
1629
+ < div xlinkHref = "#" />
1630
+ </ foreignObject >
1631
+ </ svg >
1632
+ </ body >
1633
+ </ html >
1634
+ ) ;
1635
1635
1636
- const expected =
1637
- '<html><head><meta charset="utf=8"/><meta http-equiv="refresh"/><link rel="preconnect" href="https://foo.com" crossorigin/></head><body><img srcset="foo.png, foo2.png 2x"/><svg xml:space="preserve" viewBox="0 0 10 10" fill-rule="nonzero"><foreignObject><div xlink:href="#"></div></foreignObject></svg></body></html>' ;
1636
+ const expected =
1637
+ '<html><head><meta charset="utf=8"/><meta http-equiv="refresh"/><link rel="preconnect" href="https://foo.com" crossorigin/><link rel="preconnect" href="https://bar.com" /></head><body><img srcset="foo.png, foo2.png 2x"/><svg xml:space="preserve" viewBox="0 0 10 10" fill-rule="nonzero"><foreignObject><div xlink:href="#"></div></foreignObject></svg></body></html>' ;
1638
1638
1639
- const rendered = render ( content , { } , { attrHook } ) ;
1640
- expect ( rendered ) . to . equal ( expected ) ;
1641
- } ) ;
1639
+ const rendered = render ( content , { } , { attributeHook } ) ;
1640
+ expect ( rendered ) . to . equal ( expected ) ;
1642
1641
} ) ;
1643
1642
} ) ;
1644
1643
} ) ;
0 commit comments