|
|
@@ -64,6 +64,15 @@ export function parse (
|
|
|
}
|
|
|
|
|
|
tag = tag.toLowerCase()
|
|
|
+
|
|
|
+ // check namespace.
|
|
|
+ // inherit parent ns if there is one
|
|
|
+ const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag)
|
|
|
+ // handle IE svg bug
|
|
|
+ if (options.isIE && ns === 'svg') {
|
|
|
+ attrs = guardIESVGBug(attrs)
|
|
|
+ }
|
|
|
+
|
|
|
const element: ASTElement = {
|
|
|
type: 1,
|
|
|
tag,
|
|
|
@@ -72,6 +81,9 @@ export function parse (
|
|
|
parent: currentParent,
|
|
|
children: []
|
|
|
}
|
|
|
+ if (ns) {
|
|
|
+ element.ns = ns
|
|
|
+ }
|
|
|
|
|
|
if (isForbiddenTag(element)) {
|
|
|
element.forbidden = true
|
|
|
@@ -82,14 +94,6 @@ export function parse (
|
|
|
)
|
|
|
}
|
|
|
|
|
|
- // check namespace.
|
|
|
- // inherit parent ns if there is one
|
|
|
- let ns
|
|
|
- if ((ns = currentParent && currentParent.ns) ||
|
|
|
- (ns = platformGetTagNamespace(tag))) {
|
|
|
- element.ns = ns
|
|
|
- }
|
|
|
-
|
|
|
if (!inPre) {
|
|
|
processPre(element)
|
|
|
if (element.pre) {
|
|
|
@@ -395,3 +399,17 @@ function isForbiddenTag (el): boolean {
|
|
|
))
|
|
|
)
|
|
|
}
|
|
|
+
|
|
|
+const ieNSBug = /^xmlns:NS\d+/
|
|
|
+const ieNSPrefix = /^NS\d+:/
|
|
|
+function guardIESVGBug (attrs) {
|
|
|
+ const res = []
|
|
|
+ for (let i = 0; i < attrs.length; i++) {
|
|
|
+ const attr = attrs[i]
|
|
|
+ if (!ieNSBug.test(attr.name)) {
|
|
|
+ attr.name = attr.name.replace(ieNSPrefix, '')
|
|
|
+ res.push(attr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res
|
|
|
+}
|