浏览代码

default x-data to '{}' to in mutation observer intialiser

Hugo Di Francesco 5 年之前
父节点
当前提交
4bdd3edb1d
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/component.js

+ 1 - 1
src/component.js

@@ -343,7 +343,7 @@ export default class Component {
                 if (! (closestParentComponent && closestParentComponent.isSameNode(this.$el))) continue
 
                 if (mutations[i].type === 'attributes' && mutations[i].attributeName === 'x-data') {
-                    const rawData = saferEval(mutations[i].target.getAttribute('x-data'), { $el: this.$el })
+                    const rawData = saferEval(mutations[i].target.getAttribute('x-data') || '{}', { $el: this.$el })
 
                     Object.keys(rawData).forEach(key => {
                         if (this.$data[key] !== rawData[key]) {