ソースを参照

start using Object.create

Adam Shaw 8 年 前
コミット
590279fb6a
3 ファイル変更3 行追加12 行削除
  1. 2 2
      src/Calendar.moment.js
  2. 1 1
      src/common/Class.js
  3. 0 9
      src/util.js

+ 2 - 2
src/Calendar.moment.js

@@ -27,7 +27,7 @@ Calendar.mixin({
 				weekNumberCalculation = 'ISO'; // normalize
 			}
 
-			var localeData = createObject( // make a cheap copy
+			var localeData = Object.create( // make a cheap copy
 				getMomentLocaleData(opts.locale) // will fall back to en
 			);
 
@@ -48,7 +48,7 @@ Calendar.mixin({
 				firstDay = 1;
 			}
 			if (firstDay != null) {
-				_week = createObject(localeData._week); // _week: { dow: # }
+				_week = Object.create(localeData._week); // _week: { dow: # }
 				_week.dow = firstDay;
 				localeData._week = _week;
 			}

+ 1 - 1
src/common/Class.js

@@ -40,7 +40,7 @@ function extendClass(superClass, members) {
 	}
 
 	// build the base prototype for the subclass, which is an new object chained to the superclass's prototype
-	subClass.prototype = createObject(superClass.prototype);
+	subClass.prototype = Object.create(superClass.prototype);
 
 	// copy each member variable/method onto the the subclass's prototype
 	copyOwnProps(members, subClass.prototype);

+ 0 - 9
src/util.js

@@ -862,15 +862,6 @@ function mergeProps(propObjs, complexProps) {
 }
 
 
-// Create an object that has the given prototype. Just like Object.create
-function createObject(proto) {
-	var f = function() {};
-	f.prototype = proto;
-	return new f();
-}
-FC.createObject = createObject;
-
-
 function copyOwnProps(src, dest) {
 	for (var name in src) {
 		if (hasOwnProp(src, name)) {