Evan You 10 лет назад
Родитель
Сommit
6816a6dc71
2 измененных файлов с 5 добавлено и 4 удалено
  1. 4 2
      src/runtime/dom-updater/node-ops.js
  2. 1 2
      src/runtime/vdom/create-updater.js

+ 4 - 2
src/runtime/dom-updater/node-ops.js

@@ -1,9 +1,11 @@
+const svgNS = 'http://www.w3.org/2000/svg'
+
 export function createElement (tagName) {
   return document.createElement(tagName)
 }
 
-export function createElementNS (namespaceURI, qualifiedName) {
-  return document.createElementNS(namespaceURI, qualifiedName)
+export function createSVGElement (tagName) {
+  return document.createElementNS(svgNS, tagName)
 }
 
 export function createTextNode (text) {

+ 1 - 2
src/runtime/vdom/create-updater.js

@@ -9,7 +9,6 @@ import { isPrimitive, warn } from '../util/index'
 
 const emptyNode = VNode('', {}, [])
 const hooks = ['create', 'update', 'remove', 'destroy', 'pre', 'post']
-const svgNS = 'http://www.w3.org/2000/svg'
 
 function isUndef (s) {
   return s === undefined
@@ -77,7 +76,7 @@ export default function createUpdater (backend) {
     const tag = vnode.tag
     if (isDef(tag)) {
       elm = vnode.elm = isDef(data) && data.svg
-        ? nodeOps.createElementNS(svgNS, tag)
+        ? nodeOps.createSVGElement(tag)
         : nodeOps.createElement(tag)
       if (Array.isArray(children)) {
         for (i = 0; i < children.length; ++i) {