@@ -91,6 +91,12 @@ export class LiteParser implements MinDOMParser<LiteDocument> {
9191 script : true
9292 } ;
9393
94+ public static XMLNS : { [ name : string ] : string } = {
95+ svg : 'http://www.w3.org/2000/svg' ,
96+ math : 'http://www.w3.org/1998/Math/MathML' ,
97+ html : 'http://www.w3.org/1999/xhtml'
98+ } ;
99+
94100 /**
95101 * @override
96102 */
@@ -365,8 +371,18 @@ export class LiteParser implements MinDOMParser<LiteDocument> {
365371 */
366372 protected allAttributes ( adaptor : LiteAdaptor , node : LiteElement , xml : boolean ) : AttributeData [ ] {
367373 let attributes = adaptor . allAttributes ( node ) ;
374+ //
375+ // If we aren't in XML mode, just use the attributes given
376+ //
377+ if ( ! xml ) {
378+ return attributes ;
379+ }
380+ //
381+ // Check that we know the namespace for the kind of node
382+ //
368383 const kind = adaptor . kind ( node ) ;
369- if ( ! xml || ( kind !== 'svg' && kind !== 'math' && kind !== 'html' ) ) {
384+ const xmlns = ( this . constructor as typeof LiteParser ) . XMLNS ;
385+ if ( ! xmlns . hasOwnProperty ( kind ) ) {
370386 return attributes ;
371387 }
372388 //
@@ -380,14 +396,7 @@ export class LiteParser implements MinDOMParser<LiteDocument> {
380396 //
381397 // Add one of it is missing
382398 //
383- attributes . push ( {
384- name : 'xmlns' ,
385- value : ( {
386- svg : 'http://www.w3.org/2000/svg' ,
387- math : 'http://www.w3.org/1998/Math/MathML' ,
388- html : 'http://www.w3.org/1999/xhtml'
389- } ) [ kind ]
390- } ) ;
399+ attributes . push ( { name : 'xmlns' , value : xmlns [ kind ] } ) ;
391400 return attributes ;
392401 }
393402
0 commit comments