mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -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"
|
//#include "../lib/bootstrap.js"
|
||||||
|
|
||||||
Base.inject({
|
Base.inject({
|
||||||
statics: {
|
statics: true,
|
||||||
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;
|
|
||||||
},
|
|
||||||
|
|
||||||
capitalize: function(str) {
|
read: function(args, index, length) {
|
||||||
return str.replace(/\b[a-z]/g, function(match) {
|
var index = index || 0, length = length || args.length - index;
|
||||||
return match.toUpperCase();
|
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