mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Use the new statics: true setting for Base injection, and fix Array.prototype.slice issue in Base.read().
This commit is contained in:
parent
3f0a45a7c2
commit
cfb7d195c0
1 changed files with 19 additions and 19 deletions
38
src/paper.js
38
src/paper.js
|
@ -13,27 +13,27 @@ this.install = function(scope) {
|
|||
//#include "../lib/bootstrap.js"
|
||||
|
||||
Base.inject({
|
||||
statics: {
|
||||
read: function(args, index, length) {
|
||||
var index = index || 0, length = length || args.length - index;
|
||||
if (length <= 1) {
|
||||
var arg = args[index];
|
||||
// Return null when nothing was provided
|
||||
if (arg instanceof this || arg == null)
|
||||
return arg;
|
||||
}
|
||||
var obj = new this(this.dont);
|
||||
obj = obj.initialize.apply(obj, index > 0 || length < args.length
|
||||
? slice.call(args, index, index + length)
|
||||
: args) || obj;
|
||||
return obj;
|
||||
},
|
||||
statics: true,
|
||||
|
||||
capitalize: function(str) {
|
||||
return str.replace(/\b[a-z]/g, function(match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
read: function(args, index, length) {
|
||||
var index = index || 0, length = length || args.length - index;
|
||||
if (length <= 1) {
|
||||
var arg = args[index];
|
||||
// Return null when nothing was provided
|
||||
if (arg instanceof this || arg == null)
|
||||
return arg;
|
||||
}
|
||||
var obj = new this(this.dont);
|
||||
obj = obj.initialize.apply(obj, index > 0 || length < args.length
|
||||
? Array.prototype.slice.call(args, index, index + length)
|
||||
: args) || obj;
|
||||
return obj;
|
||||
},
|
||||
|
||||
capitalize: function(str) {
|
||||
return str.replace(/\b[a-z]/g, function(match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue