3
3
var html = require ( 'property-information/html' )
4
4
var svg = require ( 'property-information/svg' )
5
5
var find = require ( 'property-information/find' )
6
+ var ns = require ( 'web-namespaces' )
7
+ var s = require ( 'hastscript/svg' )
6
8
var h = require ( 'hastscript' )
7
9
var xtend = require ( 'xtend' )
8
10
var count = require ( 'ccount' )
@@ -48,8 +50,8 @@ function transform(ast, config) {
48
50
var node
49
51
var pos
50
52
51
- if ( fn === element && schema . space === 'html' && ast . nodeName === 'svg' ) {
52
- config . schema = svg
53
+ if ( fn === element ) {
54
+ config . schema = ast . namespaceURI === ns . svg ? svg : html
53
55
}
54
56
55
57
if ( ast . childNodes ) {
@@ -131,6 +133,7 @@ function comment(ast) {
131
133
132
134
/* Transform an element. */
133
135
function element ( ast , children , config ) {
136
+ var fn = config . schema . space === 'svg' ? s : h
134
137
var name = ast . tagName
135
138
var attributes = ast . attrs
136
139
var length = attributes . length
@@ -149,7 +152,7 @@ function element(ast, children, config) {
149
152
props [ prop ] = attribute . value
150
153
}
151
154
152
- node = h ( name , props , children )
155
+ node = fn ( name , props , children )
153
156
154
157
if ( name === 'template' && 'content' in ast ) {
155
158
pos = ast . sourceCodeLocation
0 commit comments