Switch back from using 'x' in obj to obj.x != null in basic type constructors, since 'x' in <primitive type value> would throw an exception.

This commit is contained in:
Jürg Lehni 2012-11-28 22:08:56 -08:00
parent d45a4ce8ad
commit 07688a685e
3 changed files with 6 additions and 6 deletions

View file

@ -148,13 +148,13 @@ var Point = this.Point = Base.extend(/** @lends Point# */{
if (Array.isArray(arg0)) {
this.x = arg0[0];
this.y = arg0.length > 1 ? arg0[1] : arg0[0];
} else if ('x' in arg0) {
} else if (arg0.x != null) {
this.x = arg0.x;
this.y = arg0.y;
} else if ('width' in arg0) {
} else if (arg0.width != null) {
this.x = arg0.width;
this.y = arg0.height;
} else if ('angle' in arg0) {
} else if (arg0.angle != null) {
this.x = arg0.length;
this.y = 0;
this.setAngle(arg0.angle);

View file

@ -71,7 +71,7 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
this.x = this.y = this.width = this.height = 0;
if (this._read)
this._read = arg0 === null ? 1 : 0;
} else if (arguments.length > 1 && !('width' in arg0)) {
} else if (arguments.length > 1 && arg0.width == null) {
// We're checking arg0.width to rule out Rectangles, which are
// handled separately below.
// Read a point argument and look at the next value to see wether

View file

@ -109,10 +109,10 @@ var Size = this.Size = Base.extend(/** @lends Size# */{
if (Array.isArray(arg0)) {
this.width = arg0[0];
this.height = arg0.length > 1 ? arg0[1] : arg0[0];
} else if ('width' in arg0) {
} else if (arg0.width != null) {
this.width = arg0.width;
this.height = arg0.height;
} else if ('x' in arg0) {
} else if (arg0.x != null) {
this.width = arg0.x;
this.height = arg0.y;
} else {