mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-14 08:49:50 -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) {
|
isArray = Array.isArray = Array.isArray || function(obj) {
|
||||||
return toString.call(obj) === '[object Array]';
|
return toString.call(obj) === '[object Array]';
|
||||||
},
|
},
|
||||||
isObject = function(obj) {
|
|
||||||
return toString.call(obj) === '[object Object]';
|
|
||||||
},
|
|
||||||
slice = proto.slice,
|
slice = proto.slice,
|
||||||
forEach = proto.forEach || function(iter, bind) {
|
forEach = proto.forEach || function(iter, bind) {
|
||||||
for (var i = 0, l = this.length; i < l; i++)
|
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.
|
// Expose some local privates as Base generics.
|
||||||
each: each,
|
each: each,
|
||||||
clone: clone,
|
clone: clone,
|
||||||
|
define: define,
|
||||||
|
describe: describe,
|
||||||
|
iterator: iterator,
|
||||||
|
|
||||||
// Base.create does something different from Object.create, it only
|
// Base.create does something different from Object.create, it only
|
||||||
// works on constructors and uses their prototype.
|
// works on constructors and uses their prototype.
|
||||||
create: function(ctor) {
|
create: function(ctor) {
|
||||||
return create(ctor.prototype);
|
return create(ctor.prototype);
|
||||||
},
|
},
|
||||||
define: define,
|
|
||||||
describe: describe,
|
isObject: function(obj) {
|
||||||
iterator: iterator,
|
return obj !== null && typeof obj === 'object'
|
||||||
isObject: isObject,
|
&& Object.getPrototypeOf(obj) === Object.prototype;
|
||||||
|
},
|
||||||
|
|
||||||
check: function(obj) {
|
check: function(obj) {
|
||||||
return !!(obj || obj === 0);
|
return !!(obj || obj === 0);
|
||||||
|
|
Loading…
Reference in a new issue