Evan You 10 лет назад
Родитель
Сommit
a4cfd2b58c
1 измененных файлов с 9 добавлено и 6 удалено
  1. 9 6
      src/util/dom.js

+ 9 - 6
src/util/dom.js

@@ -168,17 +168,20 @@ export function off (el, event, cb) {
  * In IE9, setAttribute('class') will result in empty class
  * In IE9, setAttribute('class') will result in empty class
  * if the element also has the :class attribute; However in
  * if the element also has the :class attribute; However in
  * PhantomJS, setting `className` does not work on SVG elements...
  * PhantomJS, setting `className` does not work on SVG elements...
- * So we have to do a conditional detection here.
+ * So we have to do a conditional check here.
+ *
+ * @param {Element} el
+ * @param {String} cls
  */
  */
 
 
-const setClass = isIE9
-  ? function (el, cls) {
-    /* istanbul ignore next */
+function setClass (el, cls) {
+  /* istanbul ignore if */
+  if (isIE9 && el.hasOwnProperty('className')) {
     el.className = cls
     el.className = cls
-  }
-  : function (el, cls) {
+  } else {
     el.setAttribute('class', cls)
     el.setAttribute('class', cls)
   }
   }
+}
 
 
 /**
 /**
  * Add class with compatibility for IE & SVG
  * Add class with compatibility for IE & SVG