diff --git a/lib/bootstrap.js b/lib/bootstrap.js index 1a08c7c0..a92f0308 100644 --- a/lib/bootstrap.js +++ b/lib/bootstrap.js @@ -147,8 +147,9 @@ var Base = new function() { // Bootstrap scope // with optional arguments and as beans should not declare // the parameters and use the arguments array internally // instead. - if (beans && val.length === 0 - && (bean = name.match(/^(get|is)(([A-Z])(.*))$/))) + if (beans && (bean = name.match(/^(get|is)(([A-Z])(.*))$/)) + // Reg-exp to detect non-hidden parameters + && !/^function\s*\(.*\b[^_,].*\)/.test(val)) beans.push([ bean[3].toLowerCase() + bean[4], bean[2] ]); } // No need to look up getter if this is a function already. diff --git a/src/basic/Point.js b/src/basic/Point.js index de3b5b1c..f750f9d9 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -504,9 +504,9 @@ var Point = this.Point = Base.extend(/** @lends Point# */{ * @bean * @type Number */ - getAngle: function(/* point */) { + getAngle: function(_point) { // Hide parameters from Bootstrap so it injects bean too - return this.getAngleInRadians(arguments[0]) * 180 / Math.PI; + return this.getAngleInRadians(_point) * 180 / Math.PI; }, setAngle: function(angle) { @@ -542,9 +542,9 @@ var Point = this.Point = Base.extend(/** @lends Point# */{ * @bean * @type Number */ - getAngleInRadians: function(/* point */) { + getAngleInRadians: function(_point) { // Hide parameters from Bootstrap so it injects bean too - if (arguments[0] === undefined) { + if (_point === undefined) { if (this._angle == null) this._angle = Math.atan2(this.y, this.x); return this._angle; @@ -559,8 +559,8 @@ var Point = this.Point = Base.extend(/** @lends Point# */{ } }, - getAngleInDegrees: function(/* point */) { - return this.getAngle(arguments[0]); + getAngleInDegrees: function(_point) { + return this.getAngle(_point); }, /** diff --git a/src/basic/Rectangle.js b/src/basic/Rectangle.js index 1621a8c1..491e20ff 100644 --- a/src/basic/Rectangle.js +++ b/src/basic/Rectangle.js @@ -167,11 +167,10 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{ * @type Point * @bean */ - getPoint: function(/* dontLink */) { - // Pass on the optional argument dontLink which tells LinkedPoint to + getPoint: function(_dontLink) { + // Pass on the optional argument _dontLink which tells LinkedPoint to // produce a normal point instead. Used internally for speed reasons. - return LinkedPoint.create(this, 'setPoint', this.x, this.y, - arguments[0]); + return LinkedPoint.create(this, 'setPoint', this.x, this.y, _dontLink); }, setPoint: function(point) { @@ -181,16 +180,16 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{ return this; }, + /** * The size of the rectangle * * @type Size * @bean */ - getSize: function(/* dontLink */) { - // See Rectangle#getPoint() about arguments[0] + getSize: function(_dontLink) { return LinkedSize.create(this, 'setSize', this.width, this.height, - arguments[0]); + _dontLink); }, setSize: function(size) { @@ -308,9 +307,9 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{ * @type Point * @bean */ - getCenter: function(/* dontLink */) { + getCenter: function(_dontLink) { return LinkedPoint.create(this, 'setCenter', - this.getCenterX(), this.getCenterY(), arguments[0]); + this.getCenterX(), this.getCenterY(), _dontLink); }, setCenter: function(point) { @@ -726,9 +725,9 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{ setY = 'set' + y, get = 'get' + part, set = 'set' + part; - this[get] = function(/* dontLink */) { + this[get] = function(_dontLink) { return LinkedPoint.create(this, set, - this[getX](), this[getY](), arguments[0]); + this[getX](), this[getY](), _dontLink); }; this[set] = function(point) { point = Point.read(arguments); diff --git a/src/item/Item.js b/src/item/Item.js index 86fda596..8ddba77d 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -512,7 +512,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{ * // Move the circle 100 points to the right * circle.position.x += 100; */ - getPosition: function(/* dontLink */) { + getPosition: function(_dontLink) { // Cache position value. // Pass true for dontLink in getCenter(), so receive back a normal point var pos = this._position @@ -521,7 +521,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{ // use them to calculate the difference in #setPosition, as when it is // modified, it would hold new values already and only then cause the // calling of #setPosition. - return arguments[0] ? pos + return _dontLink ? pos : LinkedPoint.create(this, 'setPosition', pos.x, pos.y); }, @@ -553,15 +553,14 @@ function(name) { // Produce getters for bounds properties. These handle caching, matrices // and redirect the call to the private _getBounds, which can be // overridden by subclasses, see below. - this[name] = function(/* matrix */) { + this[name] = function(_matrix) { var getter = this._boundsGetter, bounds = this._getCachedBounds( // Allow subclasses to override _boundsGetter if they use the // same calculations for multiple type of bounds. // The default is name: typeof getter == 'string' ? getter : getter && getter[name] || name, - // Pass on the optional matrix - arguments[0]); + _matrix); // If we're returning 'bounds', create a LinkedRectangle that uses the // setBounds() setter to update the Item whenever the bounds are // changed: diff --git a/src/item/Raster.js b/src/item/Raster.js index 1f8b7398..327d68e9 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -154,13 +154,13 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{ * @type Context * @bean */ - getContext: function(/* notifyChange */) { + getContext: function(_notifyChange) { if (!this._context) this._context = this.getCanvas().getContext('2d'); // Support a hidden parameter that indicates if the context will be used // to modify the Raster object. We can notify such changes ahead since // they are only used afterwards for redrawing. - if (arguments[0]) + if (_notifyChange) this._changed(/*#=*/ Change.PIXELS); return this._context; }, diff --git a/src/path/Curve.js b/src/path/Curve.js index 75a7a6ef..45b26e7a 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -228,14 +228,12 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{ * @type Number * @bean */ - getLength: function(/* from, to */) { - // Hide parameters from Bootstrap so it injects bean too - var from = arguments[0], - to = arguments[1], - fullLength = arguments.length == 0 || from == 0 && to == 1; + // Hide parameters from Bootstrap so it injects bean too + getLength: function(_from, _to) { + var fullLength = arguments.length == 0 || _from == 0 && _to == 1; if (fullLength && this._length != null) return this._length; - var length = Curve.getLength(this.getValues(), from, to); + var length = Curve.getLength(this.getValues(), _from, _to); if (fullLength) this._length = length; return length; diff --git a/src/path/Path.js b/src/path/Path.js index 462b5dd1..0b58f7e8 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -131,7 +131,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ * @type Curve[] * @bean */ - getCurves: function(/* includeFill */) { + getCurves: function(_includeFill) { var curves = this._curves, segments = this._segments; if (!curves) { @@ -148,7 +148,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ // If we're asked to include the closing curve for fill, even if the // path is not closed for stroke, create a new uncached array and add // the closing curve. Used in Path#contains() - if (arguments[0] && !this._closed && this._style._fillColor) { + if (_includeFill && !this._closed && this._style._fillColor) { curves = curves.concat([ Curve.create(this, segments[segments.length - 1], segments[0]) ]);