mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-13 16:33:28 -04:00
Improve Base.isObject() to only return true for real "vanilla" JS objects.
This commit is contained in:
parent
1046e440e8
commit
81b8a57a7c
1 changed files with 9 additions and 7 deletions
16
lib/bootstrap.js
vendored
16
lib/bootstrap.js
vendored
|
@ -19,9 +19,6 @@ var Base = new function() { // Bootstrap scope
|
|||
isArray = Array.isArray = Array.isArray || function(obj) {
|
||||
return toString.call(obj) === '[object Array]';
|
||||
},
|
||||
isObject = function(obj) {
|
||||
return toString.call(obj) === '[object Object]';
|
||||
},
|
||||
slice = proto.slice,
|
||||
forEach = proto.forEach || function(iter, bind) {
|
||||
for (var i = 0, l = this.length; i < l; i++)
|
||||
|
@ -325,15 +322,20 @@ var Base = new function() { // Bootstrap scope
|
|||
// Expose some local privates as Base generics.
|
||||
each: each,
|
||||
clone: clone,
|
||||
define: define,
|
||||
describe: describe,
|
||||
iterator: iterator,
|
||||
|
||||
// Base.create does something different from Object.create, it only
|
||||
// works on constructors and uses their prototype.
|
||||
create: function(ctor) {
|
||||
return create(ctor.prototype);
|
||||
},
|
||||
define: define,
|
||||
describe: describe,
|
||||
iterator: iterator,
|
||||
isObject: isObject,
|
||||
|
||||
isObject: function(obj) {
|
||||
return obj !== null && typeof obj === 'object'
|
||||
&& Object.getPrototypeOf(obj) === Object.prototype;
|
||||
},
|
||||
|
||||
check: function(obj) {
|
||||
return !!(obj || obj === 0);
|
||||
|
|
Loading…
Reference in a new issue