@@ -7,7 +7,14 @@ import {
7
7
Fragment ,
8
8
type JSXOutput ,
9
9
} from '@qwik.dev/core' ;
10
- import { HTML_NS , MATH_NS , QContainerAttr , SVG_NS } from '../shared/utils/markers' ;
10
+ import {
11
+ HTML_NS ,
12
+ MATH_NS ,
13
+ QContainerAttr ,
14
+ SVG_NS ,
15
+ XLINK_NS ,
16
+ XML_NS ,
17
+ } from '../shared/utils/markers' ;
11
18
import { QContainerValue } from '../shared/types' ;
12
19
13
20
const debug = false ; //true;
@@ -346,6 +353,44 @@ describe.each([
346
353
</ svg >
347
354
) ;
348
355
} ) ;
356
+
357
+ describe ( 'xlink and xml namespaces' , ( ) => {
358
+ it ( 'should render xlink:href and xml:lang' , async ( ) => {
359
+ const SvgComp = component$ ( ( ) => {
360
+ return (
361
+ < svg xmlns = "http://www.w3.org/2000/svg" xlink :href = "http://www.w3.org/1999/xlink" >
362
+ < g >
363
+ < mask id = "logo-d" fill = "#fff" >
364
+ < use xlink :href = "#logo-c" > </ use >
365
+ </ mask >
366
+ </ g >
367
+ < text xml :lang = "en-US" > This is some English text</ text >
368
+ </ svg >
369
+ ) ;
370
+ } ) ;
371
+ const { vNode, document } = await render ( < SvgComp /> , { debug } ) ;
372
+ expect ( vNode ) . toMatchVDOM (
373
+ < Component >
374
+ < svg xmlns = "http://www.w3.org/2000/svg" xlink :href = "http://www.w3.org/1999/xlink" >
375
+ < g >
376
+ < mask id = "logo-d" fill = "#fff" >
377
+ < use xlink :href = "#logo-c" > </ use >
378
+ </ mask >
379
+ </ g >
380
+ < text xml :lang = "en-US" > This is some English text</ text >
381
+ </ svg >
382
+ </ Component >
383
+ ) ;
384
+
385
+ const useElement = document . querySelector ( 'use' ) ;
386
+ const xLinkHref = useElement ?. attributes . getNamedItem ( 'xlink:href' ) ;
387
+ expect ( xLinkHref ?. namespaceURI ) . toEqual ( XLINK_NS ) ;
388
+
389
+ const textElement = document . querySelector ( 'text' ) ;
390
+ const xmlLang = textElement ?. attributes . getNamedItem ( 'xml:lang' ) ;
391
+ expect ( xmlLang ?. namespaceURI ) . toEqual ( XML_NS ) ;
392
+ } ) ;
393
+ } ) ;
349
394
} ) ;
350
395
351
396
describe ( 'math' , ( ) => {
0 commit comments