Skip to content

Commit d6c0c9d

Browse files
committed
修复使用Object.create引起的兼容性问题
Fix #173
1 parent ecfc20c commit d6c0c9d

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/Model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ define(
200200
// 如果prototype上的属性是引用类型,则复制一份,
201201
// 防止因共享修改导致的问题
202202
if (!this.hasOwnProperty('datasource') && this.datasource) {
203-
this.datasource = Object.create ? Object.create(this.datasource) : u.clone(this.datasource);
203+
this.datasource = u.clone(this.datasource);
204204
}
205205

206206
if (context) {

src/View.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ define(
1111
var util = require('./util');
1212
var u = require('underscore');
1313

14-
function create(oringin) {
15-
return Object.create ? Object.create(oringin) : u.clone(oringin);
16-
}
17-
1814
/**
1915
* @class View
2016
*
@@ -35,11 +31,11 @@ define(
3531
// 如果prototype上的属性是引用类型,则复制一份,
3632
// 防止因共享修改导致的问题
3733
if (!this.hasOwnProperty('uiProperties') && this.uiProperties) {
38-
this.uiProperties = create(this.uiProperties);
34+
this.uiProperties = u.clone(this.uiProperties);
3935
}
4036

4137
if (!this.hasOwnProperty('uiEvents') && this.uiEvents) {
42-
this.uiEvents = create(this.uiEvents);
38+
this.uiEvents = u.clone(this.uiEvents);
4339
}
4440

4541
this.initialize();

src/util.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ define(
5959
// 因为自己实现的`bind`很会影响调试时的单步调试,
6060
// 跳进一个函数的时候还要经过这个`bind`几步很烦,原生的就不会
6161
var nativeBind = Function.prototype.bind;
62+
6263
/**
6364
* 固定函数的`this`变量和若干参数
6465
*
6566
* @param {Function} fn 操作的目标函数
6667
* @param {Mixed} context 函数的`this`变量
67-
* @param {Mixed...} args 固定的参数
68+
* @param {...Mixed} args 固定的参数
6869
* @return {Function} 固定了`this`变量和若干参数后的新函数对象
6970
*/
7071
util.bind = nativeBind

0 commit comments

Comments
 (0)